[英]Jest "No tests found" after update VSCode to 1.32.1
I'm using debugging jest with vscode config, here is launch.json
configurations:我正在使用带有 vscode 配置的调试玩笑,这里是launch.json
配置:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Jest Current File",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": [
"${relativeFile}"
],
"env": {
"cross-env": "1",
"NODE_PATH": "./src",
"__PLATFORM__": " WEB",
},
"runtimeArgs": [
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"windows": {
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
}
}
]
}
This configurations worked properly until I updated VSCode to 1.32.1.在我将 VSCode 更新到 1.32.1 之前,此配置工作正常。 Now when I run Jest current file, the console prints out like this:现在,当我运行 Jest 当前文件时,控制台会打印出如下内容:
Debugger attached.
No tests found
In D:\workspace\my-project
747 files checked.
testMatch: - 747 matches
testPathIgnorePatterns: \\node_modules\\ - 747 matches
testRegex: (\\__tests__\\.*|(\.|\\)(test))\.js?$ - 15 matches
Pattern: src\utils\storage\my-file-name.test.js - 0 matches
Waiting for the debugger to disconnect...
Any help would be appreciated, thanks in advance.任何帮助将不胜感激,提前致谢。
After install old version VSCode (1.30.2), I saw the output:安装旧版本 VSCode (1.30.2) 后,我看到输出:
Test Suites: 1 passed, 1 total
Tests: 9 passed, 9 total
Snapshots: 0 total
Time: 4.866s
Ran all test suites matching /src\\utils\\storage\\my-file-name.test.js/i.
Waiting for the debugger to disconnect...
Difference is Pattern
:区别在于Pattern
:
/src\\\\utils\\\\storage\\\\my-file-name.test.js/i.
v1.30.2:/ /src\\\\utils\\\\storage\\\\my-file-name.test.js/i.
name.test.js/ /src\\\\utils\\\\storage\\\\my-file-name.test.js/i.
src\\utils\\storage\\my-file-name.test.js
v1.32.1: src\\utils\\storage\\my-file-name.test.js
VSCode change their ${relativeFile}
's seperator from \\\\
to \\
, this is why jest
couldn't find out test file VSCode 将其${relativeFile}
的分隔符从\\\\
更改为\\
,这就是为什么jest
找不到测试文件的原因
For those who are being stuck, just change "${relativeFile}"
to "${fileBasenameNoExtension}"
in launch.json
configuration:对于那些被卡住的人,只需在launch.json
配置"${fileBasenameNoExtension}"
"${relativeFile}"
更改为"${fileBasenameNoExtension}"
:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Jest Current File",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": [
"./${fileBasename}"
],
"env": {
"cross-env": "1",
"NODE_PATH": "./src",
"__PLATFORM__": " WEB",
},
"runtimeArgs": [
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"windows": {
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
}
}
]
}
更好地使用--runTestsByPath ${relativeFile}
,它始终有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.