jeudi 5 mars 2020

Encountered an nuexpected token - Jjest redux-saga core

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 whar you can do" section. So what else can I do? An my attempts may be in wrong syntax. If you can propose different, concise examples, please do! Tank you very much

Aucun commentaire:

Enregistrer un commentaire