【发布时间】:2019-02-10 23:16:34
【问题描述】:
在 VS-Code 中调试 Jest 测试时,我的断点会在我启动调试器时移动几行。
我使用正式的 recommended configuration 和纯 JavaScript(不是 Babel)。
我认为这与源地图有关。
在配置中设置"sourceMaps": false 使我的断点不再移动,而是将“真实”源代码移动了几行。
小例子:
// hello_world.test.js
funTest = require('./hello_world.js')
const x = 15
test('this is a test', () => {
expect(funTest(5)).toBe(9)
})
// hello_world.js
const funTest = () => {
return 9
}
module.exports= funTest
现在,如果您在const x = 15 设置断点,您将看到在调试会话期间它被转移到expect(funTest(5)).toBe(9)。
二手软件 VS Code:1.27.0,无扩展;开玩笑:23.5.0;节点:8.10.0; Ubuntu Linux 16.04
【问题讨论】:
-
你能添加一个最小的代码示例吗?
-
好的,我会粘贴的。
标签: debugging visual-studio-code