简体   繁体   English

如何使用 VSCode 扩展运行 Jest 测试?

[英]How can I run Jest test in band with the VSCode extension?

I want to run the Jest tests in band, because otherwise they will cause errors.我想在乐队中运行 Jest 测试,否则它们会导致错误。

But I have no clue how to solve that problem.但我不知道如何解决这个问题。 It works everything fine when I run the tests with the command line.当我使用命令行运行测试时,一切正常。

In VSCode settings, change the Jest: Path to Jest to the command line you're running.在 VSCode 设置中,将Jest: Path to Jest更改为您正在运行的命令行。 For example:例如:

npm test -- --runInBand

vscode设置截图

In new version of vscode jest.pathToJest is deprecated, instead you should set jest.jestCommandLine .在新版本的 vscode 中jest.pathToJest已被弃用,您应该设置jest.jestCommandLine You can either use the settings panel to set the value for the jestCommandLine .您可以使用设置面板来设置jestCommandLine的值。 like this:像这样: 在此处输入图像描述

Or you can manually update the settings.json like this:或者您可以像这样手动更新settings.json

"jest.jestCommandLine": "\"./node_modules/.bin/jest\" --runInBand"

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

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