-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Open
Labels
Description
Version
26.6.0
Steps to reproduce
I added the @hello-pangea/dnd (version 18.0.1) library to my application, When I ran tests I started to get the following error
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:
• If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/en/ecmascript-modules for how to enable it.
• 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:
C:\Source\react-core\src\SumTotal.ReactCore.Web\ClientApp\node_modules\@hello-pangea\dnd\node_modules\react-redux\dist\cjs\react-redux.development.cjs:590
const contextMap = gT[ContextKey] ??= /* @__PURE__ */new Map();
^^^
SyntaxError: Unexpected token '??='
Could you please suggest how to resolve this issue?
Expected behavior
Should not through SyntaxError: Unexpected token '??='
Actual behavior
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:
• If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/en/ecmascript-modules for how to enable it.
• 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:
C:\Source\react-core\src\SumTotal.ReactCore.Web\ClientApp\node_modules\@hello-pangea\dnd\node_modules\react-redux\dist\cjs\react-redux.development.cjs:590
const contextMap = gT[ContextKey] ??= /* @__PURE__ */new Map();
^^^
SyntaxError: Unexpected token '??='
Additional context
No response
Environment
System:
OS: Windows 11 10.0.22631
CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12800H
Binaries:
Node: 14.21.3 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.22 - C:\Program Files\nodejs\yarn.CMD
npm: 6.14.18 - C:\Program Files\nodejs\npm.CMD
npmPackages:
jest: 26.6.0 => 26.6.0