小编Luk*_*ger的帖子

在 VS Code 中调试 jest 测试显示“错误:找不到模块“jest-environment-node”

我在调试笑话测试时遇到了麻烦。也许我先介绍一下我的设置:

root-dir
  test
    sample.spec.ts
  jest.config.js
  package.json
  tsconfig.json
Run Code Online (Sandbox Code Playgroud)

内容sample.spec.ts

describe('Sample', () => {
  it.concurrent('App', async () => {
    expect(true).toEqual(true); // here the breakpoint is set
});
Run Code Online (Sandbox Code Playgroud)

});

所以这里没有什么需要调试的。我在 VS Code 中安装了Jest Runner扩展。

但是,当我“单击”正上方的“调试”按钮时it,调试器启动,但显示异常:

Exception has occurred: Error: Cannot find module 'jest-environment-<path-to-my-root-dir>\node_modules\jest-environment-node\build\index.js/package.json' from '<path-to-my-root-dir>'e
Run Code Online (Sandbox Code Playgroud)

那里有什么问题呢?在node_modules目录中,jest-environment-node有 。异常的路径不正确,因此找不到package.json. 但这件事我无法影响!

我感谢您的帮助!

向大家致以亲切的问候!

node.js jestjs visual-studio-code

4
推荐指数
1
解决办法
906
查看次数

标签 统计

jestjs ×1

node.js ×1

visual-studio-code ×1