开玩笑说“未找到测试".将VSCode更新为1.32.1之后 [英] Jest "No tests found" after update VSCode to 1.32.1

查看:87
本文介绍了开玩笑说“未找到测试".将VSCode更新为1.32.1之后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有vscode config的调试玩笑,这是launch.json配置:

I'm using debugging jest with vscode config, here is launch.json configurations:

{
    "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",
            }
        }
    ]
}

在我将VSCode更新为1.32.1之前,此配置正常工作.现在,当我运行Jest当前文件时,控制台将像这样打印出来:

This configurations worked properly until I updated VSCode to 1.32.1. Now when I run Jest current file, the console prints out like this:

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.

推荐答案

在安装旧版本VSCode(1.30.2)之后,我看到了输出:

After install old version VSCode (1.30.2), I saw the output:

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...

差异为Pattern:

  • v1.30.2:/src\\utils\\storage\\my-file-name.test.js/i.
  • v1.32.1:src\utils\storage\my-file-name.test.js
  • v1.30.2: /src\\utils\\storage\\my-file-name.test.js/i.
  • v1.32.1: src\utils\storage\my-file-name.test.js

VSCode将其${relativeFile}的分隔符从\\更改为\,这就是为什么jest无法找到测试文件的原因

VSCode change their ${relativeFile}'s seperator from \\ to \, this is why jest couldn't find out test file

对于那些被卡住的人,只需在launch.json配置中将"${relativeFile}"更改为"${fileBasenameNoExtension}":

For those who are being stuck, just change "${relativeFile}" to "${fileBasenameNoExtension}" in launch.json configuration:

{
    "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",
            }
        }
    ]
}

这篇关于开玩笑说“未找到测试".将VSCode更新为1.32.1之后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆