React/Jasmine - SyntaxError: Cannot use import statement outside a module
已回答
Hi! I'm trying to configure the Jasmine test runner in IntelliJ.
/Users/clairenguyen/.nvm/versions/node/v14.17.0/bin/node /Users/clairenguyen/workspace/FLA/flash-docker-development-environment/dice/node_modules/jasmine/bin/jasmine.js --config=/Users/clairenguyen/workspace/FLA/flash-docker-development-environment/dice/spec/support/jasmine.json "--reporter=/Users/clairenguyen/Library/Application Support/JetBrains/IntelliJIdea2022.2/plugins/IdeaJasmine/lib/intellij_reporter.js"
/Users/clairenguyen/workspace/FLA/flash-docker-development-environment/dice/spec/helpers/SpecHelper.ts:1
import * as Enzyme from "enzyme";
^^^^^^
SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:984:16)
at Module._compile (internal/modules/cjs/loader.js:1032:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:933:32)
at Function.Module._load (internal/modules/cjs/loader.js:774:14)
at Module.require (internal/modules/cjs/loader.js:957:19)
at require (internal/modules/cjs/helpers.js:88:18)
at /Users/clairenguyen/workspace/FLA/flash-docker-development-environment/dice/node_modules/jasmine/lib/jasmine.js:99:5
at Array.forEach (<anonymous>)
at Jasmine.loadHelpers (/Users/clairenguyen/workspace/FLA/flash-docker-development-environment/dice/node_modules/jasmine/lib/jasmine.js:98:20)
Process finished with exit code 4

package.json:
{
....
"scripts": {
"build": "webpack -p",
"fix": "tslint --project tsconfig.json --fix",
"lint": "tslint --project tsconfig.json",
"start": "webpack-dev-server",
"test": "nyc ts-node node_modules/jasmine/bin/jasmine",
"test-nocov": "ts-node node_modules/jasmine/bin/jasmine --random=false",
"prettier-check": "prettier --check .",
"prettier-write": "prettier --write .",
"watch": "webpack --watch",
"prepare": "husky install"
},
....
I noticed in we have the `nyc ts-node` as part of the `test` script but I'm not sure how to include that in the intellij configs. Advice appreciated!
请先登录再写评论。
Wow nevermind. I answered my own question...

I added `./node_modules/nyc/bin/nyc.js ./node_modules/ts-node/dist/bin.js` to the Node Options.
If you have any other questions, please, let us know; we will be happy to help.
Hi! I'm running into this error:
I ended up creating a new stripped down version of my app with the package versions I'm using. It works in the terminal but not in the IDE; I'm getting the same error as above with this output:
Advice appreciated!
The app: https://github.com/clairenguyen/jasmine-test
Please report the issue to the plugin vendor, https://github.com/jasmine/IdeaJasmine/issues
For now, I can only suggest running tests with npm test or using Node.js run configuration: