在VS Code上调试Jest [英] Debugging Jest on VS Code
问题描述
我正在尝试使用VS Code调试Jest单元测试。我有以下配置文件设置
I'm trying to debug Jest unit tests using VS Code. I have the following config file settings
"configurations": [
{
"name": "Debug Jest Tests",
"type": "node",
"request": "launch",
"runtimeArgs": [
"--inspect-brk",
"${workspaceRoot}/node_modules//jest/bin/jest.js",
"--runInBand"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
]
但是当我运行(F5)VS Code时,出现以下错误
However when I run (F5) VS Code I get the following error
错误:测试运行完成后,AggregatedResult必须存在
Error: AggregatedResult must be present after test run is complete
知道为什么吗?
推荐答案
我正在使用基于
https://www.basefactor.com/using-visual -studio代码调试基于笑话的单元测试
文章,特别是示例 https://github.com/Lemoncode/jest-vs-code-debugging-example/blob/master/custom-solution-jest-config-file/01-implemented /.vscode/launch.json
launch.json中用于调试单个测试的部分(假设配置位于./config/test/ jest.json):
The section of launch.json to debug single test (assuming that the configuration is located in ./config/test/jest.json):
{
"type": "node",
"request": "launch",
"name": "Jest debug current file",
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
"args": [
"${fileBasename}",
"-c",
"./config/test/jest.json",
"--verbose",
"-i",
"--no-cache",
//"--watchAll"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
这篇关于在VS Code上调试Jest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!