Test suite failed to run in VSCode 1.22.2
See original GitHub issueEnvironment
node -v
: 9.11.1npm -v
: 5.6.0npm ls react-scripts
(if you haven’t ejected): no- Operating system: Microsoft Windows [Version 10.0.14393]
VSCode
: version 1.22.2
Steps to Reproduce
I was able to reproduce error with this repo https://github.com/karb0f0s/vscode-jest-test/ on Windows. Although this error doesn’t appear on MacOS. I guess it is somehow related to the way VSCode spawns jest
process.
package.json
{
"name": "app",
"private": true,
"scripts": {
"test": "jest",
"test:watch": "jest --watch",
"build": "webpack",
"watch": "webpack --watch"
},
"devDependencies": {
"@babel/cli": "^7.0.0-beta.46",
"@babel/core": "^7.0.0-beta.46",
"@babel/preset-env": "^7.0.0-beta.46",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^22.4.3",
"babel-loader": "^8.0.0-beta.2",
"jest": "^22.4.3",
"webpack": "^4.6.0",
"webpack-cli": "^2.0.15"
},
"jest": {
"verbose": true,
"bail": true,
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(js|ts)$",
"transform": {
"^.+\\.js?$": "babel-jest"
}
}
}
.babelrc
{
"presets": [
["@babel/preset-env", {
"targets": {
"browsers": ["last 2 versions", "ie >= 10"]
},
"modules": false,
"useBuiltIns": "usage",
"debug": true
}]
],
"env": {
"test": {
"presets": ["@babel/preset-env"]
}
}
}
Expected Behavior
npm test
works as expected, Debug
under the test
in source file works as expected, Debug configuration
vscode-jest-tests
works as expected, with transpilation and all
Actual Behavior
VSCode Jest plugin fails to run. Output contains:
FAIL test\countPrice.test.js
● Test suite failed to run
.\app\test\countPrice.test.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import { getBladeCount, calculateCpuPrice, calculateRamPrice } from "../src/countPrice";
^^^^^^
SyntaxError: Unexpected token import
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:316:17)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 0.23s
Ran all test suites related to changed files.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:8
- Comments:40 (9 by maintainers)
Top Results From Across the Web
Test suite failed to run in VSCode 1.22.2 - - Bountysource
VSCode Jest plugin fails to run. Output contains: FAIL test\countPrice.test.js ○ Test suite failed to run .\app\test\countPrice.test.js:1 ({"Object.
Read more >March 2018 (version 1.22) - Visual Studio Code
Update 1.22.2: The update addresses these issues. ... Auto attach to process - Automatically attach the debugger to running Node.js processes.
Read more >Testing Extensions - Visual Studio Code
Visual Studio Code supports running and debugging tests for your extension. These tests will run inside a special instance of VS Code named...
Read more >November 2022 (version 1.74) - Visual Studio Code
There are now audio cues for when notebook cells finish running. The cue is different to indicate whether the cell ran successfully or...
Read more >Command Line Interface (CLI) - Visual Studio Code
If you are looking for how to run command-line tools inside VS Code, ... If this isn't the case, you can manually add...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Based on the changes from #324 it looks like you can work around this issue by adding a
"jest.pathToJest": "npm test --"
setting in.vscode/settings.json
. The PR closed a few issues that I haven’t had time to digest so I’m not keen to revert the breaking change just yet. If anyone’s got the bandwidth, I’d love some help with a fix or help building a list of what requirements were requested in those closed issues to guide some much-needed unit and integration tests.@seanpoulter to reproduce:
create-react-app my_app
npm test
in a terminal and the tests will passsrc/App.test.js
file and VSCode will show the following error: