Redwood: At the end of the tutorial, test files created by the generator can't actually run

Created on 8 Oct 2020  Β·  12Comments  Β·  Source: redwoodjs/redwood

 FAIL   api  api/src/services/contacts/contacts.test.js
  ● Console

    console.warn
      warn prisma.disconnect() is deprecated, please use prisma.$disconnect() instead

      at NewPrismaClient.disconnect (../node_modules/@prisma/client/src/runtime/getPrismaClient.ts:472:15)
      at Object.<anonymous> (../node_modules/@redwoodjs/core/dist/configs/node/jest.setup.js:27:12)

  ● contacts β€Ί returns true

    TypeError: Cannot read property 'datamodel' of undefined

      at Object.<anonymous> (../node_modules/@redwoodjs/core/dist/configs/node/jest.setup.js:22:29)

 FAIL   api  api/src/services/posts/posts.test.js
  ● Console

    console.warn
      warn prisma.disconnect() is deprecated, please use prisma.$disconnect() instead

      at NewPrismaClient.disconnect (../node_modules/@prisma/client/src/runtime/getPrismaClient.ts:472:15)
      at Object.<anonymous> (../node_modules/@redwoodjs/core/dist/configs/node/jest.setup.js:27:12)

  ● posts β€Ί returns true

    TypeError: Cannot read property 'datamodel' of undefined

      at Object.<anonymous> (../node_modules/@redwoodjs/core/dist/configs/node/jest.setup.js:22:29)

 FAIL   web  web/src/pages/ContactPage/ContactPage.test.js
  ● Test suite failed to run

    Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

    Here's what you can do:
     β€’ To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     β€’ If you need a custom transformation specify a "transform" option in your config.
     β€’ If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/en/configuration.html

    Details:

    /Users/rob/Sites/redwoodjs/redwood-tutorial/node_modules/@apollo/client/react/hooks/useSubscription.js:1
    import { __assign } from "tslib";
    ^^^^^^

    SyntaxError: Cannot use import statement outside a module
        at compileFunction (<anonymous>)

      at Runtime._execModule (../node_modules/jest-runtime/build/index.js:1179:56)
      at Object.<anonymous> (../node_modules/@redwoodjs/web/dist/index.js:78:24)
      at Object.<anonymous> (../node_modules/@redwoodjs/testing/dist/MockProviders.js:15:12)
      at Object.<anonymous> (../node_modules/@redwoodjs/testing/dist/customRender.js:17:22)
      at Object.<anonymous> (../node_modules/@redwoodjs/testing/dist/index.js:48:21)
      at Object.<anonymous> (../node_modules/@redwoodjs/core/dist/configs/browser/jest.setup.js:16:5)

 FAIL   web  web/src/layouts/BlogLayout/BlogLayout.test.js
  ● Test suite failed to run

    Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

    Here's what you can do:
     β€’ To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     β€’ If you need a custom transformation specify a "transform" option in your config.
     β€’ If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/en/configuration.html

    Details:

    /Users/rob/Sites/redwoodjs/redwood-tutorial/node_modules/@apollo/client/react/hooks/useSubscription.js:1
    import { __assign } from "tslib";
    ^^^^^^

    SyntaxError: Cannot use import statement outside a module
        at compileFunction (<anonymous>)

      at Runtime._execModule (../node_modules/jest-runtime/build/index.js:1179:56)
      at Object.<anonymous> (../node_modules/@redwoodjs/web/dist/index.js:78:24)
      at Object.<anonymous> (../node_modules/@redwoodjs/testing/dist/MockProviders.js:15:12)
      at Object.<anonymous> (../node_modules/@redwoodjs/testing/dist/customRender.js:17:22)
      at Object.<anonymous> (../node_modules/@redwoodjs/testing/dist/index.js:48:21)
      at Object.<anonymous> (../node_modules/@redwoodjs/core/dist/configs/browser/jest.setup.js:16:5)

 FAIL   web  web/src/pages/BlogPostPage/BlogPostPage.test.js
  ● Test suite failed to run

    Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

    Here's what you can do:
     β€’ To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     β€’ If you need a custom transformation specify a "transform" option in your config.
     β€’ If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/en/configuration.html

    Details:

    /Users/rob/Sites/redwoodjs/redwood-tutorial/node_modules/@apollo/client/react/hooks/useSubscription.js:1
    import { __assign } from "tslib";
    ^^^^^^

    SyntaxError: Cannot use import statement outside a module
        at compileFunction (<anonymous>)

      at Runtime._execModule (../node_modules/jest-runtime/build/index.js:1179:56)
      at Object.<anonymous> (../node_modules/@redwoodjs/web/dist/index.js:78:24)
      at Object.<anonymous> (../node_modules/@redwoodjs/testing/dist/MockProviders.js:15:12)
      at Object.<anonymous> (../node_modules/@redwoodjs/testing/dist/customRender.js:17:22)
      at Object.<anonymous> (../node_modules/@redwoodjs/testing/dist/index.js:48:21)
      at Object.<anonymous> (../node_modules/@redwoodjs/core/dist/configs/browser/jest.setup.js:16:5)

 FAIL   web  web/src/pages/HomePage/HomePage.test.js
  ● Test suite failed to run

    Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

    Here's what you can do:
     β€’ To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     β€’ If you need a custom transformation specify a "transform" option in your config.
     β€’ If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/en/configuration.html

    Details:

    /Users/rob/Sites/redwoodjs/redwood-tutorial/node_modules/@apollo/client/react/hooks/useSubscription.js:1
    import { __assign } from "tslib";
    ^^^^^^

    SyntaxError: Cannot use import statement outside a module
        at compileFunction (<anonymous>)

      at Runtime._execModule (../node_modules/jest-runtime/build/index.js:1179:56)
      at Object.<anonymous> (../node_modules/@redwoodjs/web/dist/index.js:78:24)
      at Object.<anonymous> (../node_modules/@redwoodjs/testing/dist/MockProviders.js:15:12)
      at Object.<anonymous> (../node_modules/@redwoodjs/testing/dist/customRender.js:17:22)
      at Object.<anonymous> (../node_modules/@redwoodjs/testing/dist/index.js:48:21)
      at Object.<anonymous> (../node_modules/@redwoodjs/core/dist/configs/browser/jest.setup.js:16:5)

 FAIL   web  web/src/components/BlogPost/BlogPost.test.js
  ● Test suite failed to run

    Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

    Here's what you can do:
     β€’ To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     β€’ If you need a custom transformation specify a "transform" option in your config.
     β€’ If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/en/configuration.html

    Details:

    /Users/rob/Sites/redwoodjs/redwood-tutorial/node_modules/@apollo/client/react/hooks/useSubscription.js:1
    import { __assign } from "tslib";
    ^^^^^^

    SyntaxError: Cannot use import statement outside a module
        at compileFunction (<anonymous>)

      at Runtime._execModule (../node_modules/jest-runtime/build/index.js:1179:56)
      at Object.<anonymous> (../node_modules/@redwoodjs/web/dist/index.js:78:24)
      at Object.<anonymous> (../node_modules/@redwoodjs/testing/dist/MockProviders.js:15:12)
      at Object.<anonymous> (../node_modules/@redwoodjs/testing/dist/customRender.js:17:22)
      at Object.<anonymous> (../node_modules/@redwoodjs/testing/dist/index.js:48:21)
      at Object.<anonymous> (../node_modules/@redwoodjs/core/dist/configs/browser/jest.setup.js:16:5)

 FAIL   web  web/src/pages/AboutPage/AboutPage.test.js
  ● Test suite failed to run

    Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

    Here's what you can do:
     β€’ To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     β€’ If you need a custom transformation specify a "transform" option in your config.
     β€’ If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/en/configuration.html

    Details:

    /Users/rob/Sites/redwoodjs/redwood-tutorial/node_modules/@apollo/client/react/hooks/useSubscription.js:1
    import { __assign } from "tslib";
    ^^^^^^

    SyntaxError: Cannot use import statement outside a module
        at compileFunction (<anonymous>)

      at Runtime._execModule (../node_modules/jest-runtime/build/index.js:1179:56)
      at Object.<anonymous> (../node_modules/@redwoodjs/web/dist/index.js:78:24)
      at Object.<anonymous> (../node_modules/@redwoodjs/testing/dist/MockProviders.js:15:12)
      at Object.<anonymous> (../node_modules/@redwoodjs/testing/dist/customRender.js:17:22)
      at Object.<anonymous> (../node_modules/@redwoodjs/testing/dist/index.js:48:21)
      at Object.<anonymous> (../node_modules/@redwoodjs/core/dist/configs/browser/jest.setup.js:16:5)

 FAIL   web  web/src/components/BlogPostsCell/BlogPostsCell.test.js
  ● Test suite failed to run

    Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

    Here's what you can do:
     β€’ To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     β€’ If you need a custom transformation specify a "transform" option in your config.
     β€’ If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/en/configuration.html

    Details:

    /Users/rob/Sites/redwoodjs/redwood-tutorial/node_modules/@apollo/client/react/hooks/useSubscription.js:1
    import { __assign } from "tslib";
    ^^^^^^

    SyntaxError: Cannot use import statement outside a module
        at compileFunction (<anonymous>)

      at Runtime._execModule (../node_modules/jest-runtime/build/index.js:1179:56)
      at Object.<anonymous> (../node_modules/@redwoodjs/web/dist/index.js:78:24)
      at Object.<anonymous> (../node_modules/@redwoodjs/testing/dist/MockProviders.js:15:12)
      at Object.<anonymous> (../node_modules/@redwoodjs/testing/dist/customRender.js:17:22)
      at Object.<anonymous> (../node_modules/@redwoodjs/testing/dist/index.js:48:21)
      at Object.<anonymous> (../node_modules/@redwoodjs/core/dist/configs/browser/jest.setup.js:16:5)

 FAIL   web  web/src/components/BlogPostCell/BlogPostCell.test.js
  ● Test suite failed to run

    Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

    Here's what you can do:
     β€’ To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     β€’ If you need a custom transformation specify a "transform" option in your config.
     β€’ If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/en/configuration.html

    Details:

    /Users/rob/Sites/redwoodjs/redwood-tutorial/node_modules/@apollo/client/react/hooks/useSubscription.js:1
    import { __assign } from "tslib";
    ^^^^^^

    SyntaxError: Cannot use import statement outside a module
        at compileFunction (<anonymous>)

      at Runtime._execModule (../node_modules/jest-runtime/build/index.js:1179:56)
      at Object.<anonymous> (../node_modules/@redwoodjs/web/dist/index.js:78:24)
      at Object.<anonymous> (../node_modules/@redwoodjs/testing/dist/MockProviders.js:15:12)
      at Object.<anonymous> (../node_modules/@redwoodjs/testing/dist/customRender.js:17:22)
      at Object.<anonymous> (../node_modules/@redwoodjs/testing/dist/index.js:48:21)
      at Object.<anonymous> (../node_modules/@redwoodjs/core/dist/configs/browser/jest.setup.js:16:5)

Test Suites: 10 failed, 10 total
Tests:       2 failed, 2 total
Snapshots:   0 total
Time:        4.066 s
Ran all test suites in 2 projects.

Watch Usage: Press w to show more.
bu2-confirmed testing

Most helpful comment

All 12 comments

@cannikin So much with yarn rw test is broken right now 😒

Check out my up-to-date v1.0 column here:
https://github.com/redwoodjs/redwood/projects/4

Hopefully, that helps guide this initial draft of Tutorial Pt 2. And, of course, what's need to get things at least working.

Just realized I get totally different errors if I run yarn jest (which was my original output that I saw when I created this issue) vs yarn rw test. I replaced the errors in my original post with the yarn rw test output.

BUT I don't see anything in the v1.0 column related to what I'm seeing though...that seems more like just outstanding test stuff we want to do rather than any bug fixes?

Looks like maybe it's just a matter of including babel or some babel plugin at the right time? It doesn't like any import statements...

It's likely due to how we setup Jest config and things changing with Apollo v3. See #1264

Ahhh yep looks like the same thing. Fix that please. πŸ˜‰

I think the api side of your tests should've been fixed after this one: https://github.com/redwoodjs/redwood/pull/1207

Hmm strange, I see this happening as well. Seems like this PR wasn't released yet?

Hmm, if it gets merged I think it gets turned into a canary release automatically? Did you yarn rw update -t canary?

Yeah I did! Strange πŸ‘»

@RobertBroersma I _am_ seeing that change in main. There was an issue earlier this week β€” canaries were not installing correctly for dependent packages like cli, eslint-config, etc. You might need to re-try canary now and confirm the installed version of a package, e.g. cli, is at the correct version.

I just updated to 0.19.5-canary.18 and can verify the canary is now in all my package.json files. Still getting errors complaining about import...

 PASS   api  api/src/services/contacts/contacts.test.js
 PASS   api  api/src/services/posts/posts.test.js
 FAIL   web  web/src/pages/BlogPostPage/BlogPostPage.test.js
  ● Test suite failed to run

    Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

    Here's what you can do:
     β€’ To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     β€’ If you need a custom transformation specify a "transform" option in your config.
     β€’ If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/en/configuration.html

    Details:

    /Users/rob/Sites/redwoodjs/redwood-tutorial/node_modules/@apollo/client/react/hooks/useSubscription.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import { __assign } from "tslib";
                                                                                             ^^^^^^

    SyntaxError: Cannot use import statement outside a module

      at Runtime.createScriptFromCode (../node_modules/jest-runtime/build/index.js:1295:14)
      at Object.<anonymous> (../node_modules/@redwoodjs/web/dist/index.js:80:24)

 FAIL   web  web/src/pages/ContactPage/ContactPage.test.js
  ● Test suite failed to run

    Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

    Here's what you can do:
     β€’ To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     β€’ If you need a custom transformation specify a "transform" option in your config.
     β€’ If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/en/configuration.html

    Details:

    /Users/rob/Sites/redwoodjs/redwood-tutorial/node_modules/@apollo/client/react/hooks/useSubscription.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import { __assign } from "tslib";
                                                                                             ^^^^^^

    SyntaxError: Cannot use import statement outside a module

      at Runtime.createScriptFromCode (../node_modules/jest-runtime/build/index.js:1295:14)
      at Object.<anonymous> (../node_modules/@redwoodjs/web/dist/index.js:80:24)

 FAIL   web  web/src/pages/AboutPage/AboutPage.test.js
  ● Test suite failed to run

    Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

    Here's what you can do:
     β€’ To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     β€’ If you need a custom transformation specify a "transform" option in your config.
     β€’ If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/en/configuration.html

    Details:

    /Users/rob/Sites/redwoodjs/redwood-tutorial/node_modules/@apollo/client/react/hooks/useSubscription.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import { __assign } from "tslib";
                                                                                             ^^^^^^

    SyntaxError: Cannot use import statement outside a module

      at Runtime.createScriptFromCode (../node_modules/jest-runtime/build/index.js:1295:14)
      at Object.<anonymous> (../node_modules/@redwoodjs/web/dist/index.js:80:24)

 FAIL   web  web/src/components/BlogPost/BlogPost.test.js
  ● Test suite failed to run

    Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

    Here's what you can do:
     β€’ To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     β€’ If you need a custom transformation specify a "transform" option in your config.
     β€’ If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/en/configuration.html

    Details:

    /Users/rob/Sites/redwoodjs/redwood-tutorial/node_modules/@apollo/client/react/hooks/useSubscription.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import { __assign } from "tslib";
                                                                                             ^^^^^^

    SyntaxError: Cannot use import statement outside a module

      at Runtime.createScriptFromCode (../node_modules/jest-runtime/build/index.js:1295:14)
      at Object.<anonymous> (../node_modules/@redwoodjs/web/dist/index.js:80:24)

 FAIL   web  web/src/layouts/BlogLayout/BlogLayout.test.js
  ● Test suite failed to run

    Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

    Here's what you can do:
     β€’ To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     β€’ If you need a custom transformation specify a "transform" option in your config.
     β€’ If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/en/configuration.html

    Details:

    /Users/rob/Sites/redwoodjs/redwood-tutorial/node_modules/@apollo/client/react/hooks/useSubscription.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import { __assign } from "tslib";
                                                                                             ^^^^^^

    SyntaxError: Cannot use import statement outside a module

      at Runtime.createScriptFromCode (../node_modules/jest-runtime/build/index.js:1295:14)
      at Object.<anonymous> (../node_modules/@redwoodjs/web/dist/index.js:80:24)

 FAIL   web  web/src/pages/HomePage/HomePage.test.js
  ● Test suite failed to run

    Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

    Here's what you can do:
     β€’ To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     β€’ If you need a custom transformation specify a "transform" option in your config.
     β€’ If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/en/configuration.html

    Details:

    /Users/rob/Sites/redwoodjs/redwood-tutorial/node_modules/@apollo/client/react/hooks/useSubscription.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import { __assign } from "tslib";
                                                                                             ^^^^^^

    SyntaxError: Cannot use import statement outside a module

      at Runtime.createScriptFromCode (../node_modules/jest-runtime/build/index.js:1295:14)
      at Object.<anonymous> (../node_modules/@redwoodjs/web/dist/index.js:80:24)

 FAIL   web  web/src/components/BlogPostCell/BlogPostCell.test.js
  ● Test suite failed to run

    Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

    Here's what you can do:
     β€’ To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     β€’ If you need a custom transformation specify a "transform" option in your config.
     β€’ If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/en/configuration.html

    Details:

    /Users/rob/Sites/redwoodjs/redwood-tutorial/node_modules/@apollo/client/react/hooks/useSubscription.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import { __assign } from "tslib";
                                                                                             ^^^^^^

    SyntaxError: Cannot use import statement outside a module

      at Runtime.createScriptFromCode (../node_modules/jest-runtime/build/index.js:1295:14)
      at Object.<anonymous> (../node_modules/@redwoodjs/web/dist/index.js:80:24)

 FAIL   web  web/src/components/BlogPostsCell/BlogPostsCell.test.js
  ● Test suite failed to run

    Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

    Here's what you can do:
     β€’ To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     β€’ If you need a custom transformation specify a "transform" option in your config.
     β€’ If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/en/configuration.html

    Details:

    /Users/rob/Sites/redwoodjs/redwood-tutorial/node_modules/@apollo/client/react/hooks/useSubscription.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import { __assign } from "tslib";
                                                                                             ^^^^^^

    SyntaxError: Cannot use import statement outside a module

      at Runtime.createScriptFromCode (../node_modules/jest-runtime/build/index.js:1295:14)
      at Object.<anonymous> (../node_modules/@redwoodjs/web/dist/index.js:80:24)

Test Suites: 8 failed, 2 passed, 10 total
Tests:       2 passed, 2 total
Snapshots:   0 total
Time:        4.585 s
Ran all test suites in 2 projects.
Was this page helpful?
0 / 5 - 0 ratings