简体   繁体   English

防止 vscode jest 扩展将 cypress 测试解释为 jest 测试

[英]Prevent vscode jest extension interpreting cypress tests as jest tests

I have a create-react-app project with both jest (in ./src/components) and cypress (in ./cypress) tests.我有一个包含 jest (in ./src/components)和 cypress (in ./cypress)测试的 create-react-app 项目。 I have separate commands in my package.json file to run both test suites, and everything works as expected.我的package.json文件中有单独的命令来运行两个测试套件,一切都按预期工作。

My problem is with the vscode jest extension ( orta.vscode-jest ), which interprets my cypress tests as jest tests and tries to run them.我的问题是vscode jest 扩展( orta.vscode-jest ),它将我的cypress测试解释为 jest 测试并尝试运行它们。

I solved this by adding a line to my .vscode/settings.json file, telling the vscode jest extension ( orta.vscode-jest ) to use the correct jest command我通过在我的.vscode/settings.json文件中添加一行来解决这个问题,告诉vscode jest 扩展名 ( orta.vscode-jest ) 使用正确的 jest 命令

{
  "jest.pathToJest": "npm run test:jest --"
}

Where the test:jest command is defined in my package.json :在我的package.json定义了test:jest命令:

{
  "scripts: {
    "test:jest": "CI=true react-scripts test",
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM