Following jest's official docs to enable ES Modules here: https://jestjs.io/docs/ecmascript-modules
I've followed step 1 by inserting the following config into package.json:
"jest": {
"transform": {}
},
And then running the command they list in step 2
yarn node --experimental-vm-modules $(yarn bin jest)
Results in the following output/exception:
warning package.json: No license field
yarn node v1.22.5
warning package.json: No license field
C:\Users\david\source\repos\algo-ds\node_modules\.bin\jest:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
^^^^^^^
SyntaxError: missing ) after argument list
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1033:15)
at Module._compile (node:internal/modules/cjs/loader:1069:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47
error Command failed.
Exit code: 1
Command: C:\Program Files\nodejs\node.exe
Arguments: --experimental-vm-modules C:\Users\david\source\repos\algo-ds\node_modules\.bin\jest
Directory: C:\Users\david\source\repos\algo-ds
Output:
info Visit https://yarnpkg.com/en/docs/cli/node for documentation about this command.
package.json
{
"type": "module",
"jest": {
"transform": {}
},
"dependencies": {
"@types/jest": "^28.1.3"
},
"devDependencies": {
"jest": "^28.1.1"
},
"scripts": {
"test": "jest"
}
}
Using Node.js v16.15.1