Encountered an nuexpected token - Jjest redux-saga core

你。 提交于 2020-07-10 06:46:12

问题


I have gotten this error on different tests with Jest after some updates of React, and other npm packages, and after I have used a new npm module. I think the problem this time is laying inside the MyApp\node_modules\@redux-saga\core\dist\redux-saga-core.dev.cjs.js:734. Here is my error, where I have swapped my real project name with MyApp:

2  ● 2Test suite failed to run
2
2    ;31Jest 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"2 in your config.
2     • If you need a custom transformation specify a "transform"2 option in your config.
2     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper"2 config option.
2
2    You'll find more details and examples of these config options in the docs:
2    https://jestjs.io/docs/en/configuration.html

    ;31Details:

    MyApp\node_modules\@redux-saga\core\dist\redux-saga-core.dev.cjs.js:734
        var state = selector.apply(void 0, [env.TypeError: env.getState is not a function()].concat(args));
                                                         ^

    SyntaxError: Unexpected token :

      at ScriptTransformer._transformAndBuildScript (2node_modules/jest-runtime/build/script_transformer.js:403:17)2
2      at Object.<anonymous> (2node_modules/@redux-saga/core/dist/redux-saga-core.cjs.js:6:20)2
2      at Object.<anonymous> (2node_modules/redux-saga/dist/redux-saga-core-npm-proxy.cjs.js:7:28)2

I have tried the different suggestions in the "Here's what you can do" section. So what else can I do? An my attempts may be in wrong syntax. I am open to trying other approaches.

来源:https://stackoverflow.com/questions/60547285/encountered-an-nuexpected-token-jjest-redux-saga-core

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!