【问题标题】:Running Jest from Visual Studio Code in Windows results in no tests being found在 Windows 中从 Visual Studio Code 运行 Jest 导致找不到测试
【发布时间】:2017-05-13 16:16:37
【问题描述】:

出于某种原因,通过 Visual Studio 代码运行 jest 会返回类似于以下内容的内容:

running command> jest --no-cache No tests found In c:\Users\gusta\Documents\ts 992 files checked. testMatch: **/__tests__/**/*.js?(x),**/?(*.)(spec|test).js?(x) - 121 matches testPathIgnorePatterns: \\node_modules\\ - 7 matches Pattern: "" - 0 matches

但是,当从命令行运行测试时,它可以很好地解决测试。

C:\Users\gusta\Documents\ts>jest --no-cache PASS src\__test__\some-component.test.jsx (6.812s)

在尝试在 VSCode 中进行调试时会发生这种情况,而且在运行任务时也会发生这种情况。我的 tasks.json 看起来像这样:

{ "version": "0.1.0", "tasks": [ { "taskName": "jest", "command": "jest", "args": [ "--no-cache" ], "isShellCommand": true, "echoCommand": true, "showOutput": "always" } ] }

我的 package.json: { "name": "badgeexplorerts", "version": "0.0.1", "private": true, "scripts": { "start": "node node_modules/react-native/local-cli/cli.js start", "android": "yarn run haul start -- --platform android", "test": "jest" }, "dependencies": { "@types/jest": "^19.2.3", "react": "~15.4.1", "react-native": "0.42.3", "ts-loader": "^2.0.3", "typescript": "^2.2.2" }, "devDependencies": { "@types/react": "^15.0.24", "@types/react-native": "^0.43.12", "babel-jest": "^20.0.0", "babel-loader": "^7.0.0", "babel-preset-es2015": "^6.24.1", "haul-cli": "^0.5.0", "jest": "^20.0.0", "react-test-renderer": "~15.4.1", "ts-jest": "^20.0.2" }, "jest": { "preset": "react-native" } }

有人知道发生了什么吗?我的VSCode版本是1.12.1

【问题讨论】:

    标签: react-native visual-studio-code jestjs


    【解决方案1】:

    好的,事实证明,如果您将“版本”更改为 2.0.0,它就可以正常工作。 我无法解释,但一个有效的 task.json 看起来像这样:

    { "version": "2.0.0", "tasks": [ { "taskName": "jest", "command": "jest", "args": [ "--no-cache" ], "isShellCommand": true, "echoCommand": true, "showOutput": "always" } ]
    }

    我在节点调试配置中遇到了同样的问题,在哪里设置

    "console": "integratedTerminal" 在 launch.json 中使它工作。我无法解释它,但它对我有用。

    【讨论】:

      猜你喜欢
      • 2021-11-26
      • 1970-01-01
      • 2020-04-30
      • 2019-11-29
      • 2016-03-08
      • 2020-07-23
      • 2017-06-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多