Closed shamoq closed 7 years ago
单元测试的时候,如果是用 mm.app()
启动的,实际上只是单进程,所以无需 egg-development-proxyworker
,直接加一个常规的 configuration 连接默认端口即可。
但这里问题是被 power-assert 转码后的代码,vscode 能断点到首行,但是在源码里面打的点无法断到, WebStorm 我记得是可以的。
/cc @shepherdwind @okoala
我看了下,VSCode 调试的时候拿到的文件路径是错误了,无法定位到原文件。需要看看怎么搞~
下面vscode中打印出的日志:
SourceMaps.getMapForGeneratedPath: Using inlined sourcemap in d:\Code\github\egg-example\test\app\controller\home.test.js
SourceMap: creating for d:\Code\github\egg-example\test\app\controller\home.test.js
SourceMap: sourceRoot: undefined
SourceMap: sources: ["test\\app\\controller\\home.test.js"]
SourceMap: no sourceRoot specified, using script dirname: d:\Code\github\egg-example\test\app\controller
Warning: sourceMapPathOverrides entry does not map to an absolute path - "webpack:///./*": "${cwd}/*"
Warning: sourceMapPathOverrides entry does not map to an absolute path - "webpack:///*": "*"
Warning: sourceMapPathOverrides entry does not map to an absolute path - "meteor://💻app/*": "${cwd}/*"
SourceMaps.scriptParsed: d:\Code\github\egg-example\test\app\controller\home.test.js was just loaded and has mapped sources: ["d:\\Code\\github\\egg-example\\test\\app\\controller\\test\\app\\controller\\home.test.js"]
SourceMaps.setBP: Mapped d:\Code\github\egg-example\test\app\controller\test\app\controller\home.test.js to d:\Code\github\egg-example\test\app\controller\home.test.js
SourceMaps.setBP: Mapped d:\Code\github\egg-example\test\app\controller\test\app\controller\home.test.js:7:1 to d:\Code\github\egg-example\test\app\controller\home.test.js:37:9
SourceMaps.setBP: Mapped d:\Code\github\egg-example\test\app\controller\test\app\controller\home.test.js:14:1 to d:\Code\github\egg-example\test\app\controller\home.test.js:54:9
SourceMaps.setBP: SourceMaps are enabled but d:\Code\github\egg-example\test\app\controller\home.test.js is a runtime script
SourceMaps.setBP: Mapped d:\Code\github\egg-example\test\app\controller\home.test.js:37:9 to d:\Code\github\egg-example\test\app\controller\test\app\controller\home.test.js:7
SourceMaps.setBP: Mapped d:\Code\github\egg-example\test\app\controller\home.test.js:54:9 to d:\Code\github\egg-example\test\app\controller\test\app\controller\home.test.js:14
路径中有段是重复的,之前也出现了类似的情况~
看了下 sourceMap 提示要设置 sourceRoot
我本地用 inspector 协议已经正常断点了
但是用 旧的协议 会报错
#
# Fatal error in runtime\runtime-debug.cc, line 1424
# Check failed: args[0]->IsJSObject().
#
==== C stack trace ===============================
v8::internal::operator<< [0x00007FF63913A606+42646]
v8::internal::AllocationSpaceName [0x00007FF63907BA12+430498]
(No symbol) [0x0000015EF59843AB]
⚠️ run command --debug-brk got error: D:\Code\github\egg-example\node_modules\_mocha@3.3.0@mocha\bin\_mocha --require=D:\Code\github\egg-example\
node_modules\_co-mocha@1.2.0@co-mocha\lib\co-mocha.js,--require=D:\Code\github\egg-example\node_modules\_intelli-espower-loader@1.0.1@intelli-espower-loader\intelli-espower-loader.js,--no-timeouts,D:\Code\github\egg-example\test\.setup.js,test/app/controller/home.test.js exit with code 3221225477
Error: D:\Code\github\egg-example\node_modules\_mocha@3.3.0@mocha\bin\_mocha --require=D:\Code\github\egg-example\node_modules\_co-mocha@1.2.0@co-mocha\lib\co-mocha.js,--require=D:\Code\github\egg-example\node_modules\_intelli-espower-loader@1.0.1@intelli-espower-loader\intelli-espower-loader.js,--no-timeouts,D:\Code\github\egg-example\test\.setup.js,test/app/controller/home.test.js exit with code 3221225477
at ChildProcess.proc.once.code (D:\Code\github\egg-example\node_modules\_common-bin@2.3.0@common-bin\lib\helper.js:56:21)
at Object.onceWrapper (events.js:293:19)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:194:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
关注,typescript 呢?
@okoala 能看下你的配置吗,是需要修改哪些地方.
@a304885433 你可以看下我引用 espower source 过来的那个链接
@atian25 @okoala 看了下,还是没看懂不知道改那里,lanch里又是怎么配置。
@a304885433 改了 espower-source 的代码,等OK之后,我会更新使用步骤~
@okoala 嗯,那就等消息了,期待
已经发布了,试试
@okoala 要不要在 example 里写一个 vscode 的例子
@a304885433 我本地试已经ok了, 你先 rm 掉 node_module 然后重新安装依赖。
启动 test:
npm run test-local -- --inspect-brk
launch.json 配置:
{
"name": "Attach Test",
"type": "node",
"protocol": "inspector",
"request": "attach",
"timeout": 10000,
"restart": true,
"port": 9229
}
然后就可以进行各种断点调试,app 和 test 下断点都ok.
@popomore 这个可以有~
插件里面加一个 install.js 用来自动生成吧,如果不存在时
发自我的 iPhone
在 2017年5月5日,11:52,仙森 notifications@github.com 写道:
@popomore 这个可以有~
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
@okoala 感谢你的帮助,现在是可以调试了。调试能不能直接从vscode里进去呀,现在在终端敲个命令,vscode在去附加进程调试,感觉少许麻烦。我尝试照着原来的配置修改里一下lanch.json,可以运行调试,但是调试结束后,陆续报几个错误出来。以下是我的写法:
{
"name": "Launch Test",
"type": "node",
"request": "launch",
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"runtimeExecutable": "npm",
"windows": {
"runtimeExecutable": "npm.cmd"
},
"runtimeArgs": [
"run",
"test-local",
"--",
"--inspect-brk"
],
"port": 5858
},
{
"name": "Attach Test",
"type": "node",
"protocol": "inspector",
"request": "attach",
"timeout": 10000,
"restart": true,
"port": 9229
}
{
"name": "Test Egg",
"configurations": [
"Launch Test",
"Attach Test"
]
}
@a304885433 调试完进程就退出了啊~
@atian25 好~
@okoala 嗯,调试完成后是自动退出,不知道vscode是不是还在干什么,会提示如下3个错误。能不能把下面的错误提示干掉。
Cannot read property 'toLowerCase' of undefined
Ensure Node was launched with --inspect. Cannot connect to runtime process, timeout after 10000 ms - (reason: Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:9229).
Cannot connect to runtime process, timeout after 10000 ms - (reason: Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:5858).
@a304885433 遇到跟你一样的错误。
@tong3jie 你是陆陆续续出现这样的错误,还是一直出现?
请问问题解决了没?我的是mac vscode出现问题,配置也是这个。
调试如何忽略进入node_module文件夹?
调试如何忽略进入node_module文件夹?
可以去看看 VSCode 自己的 Debug 文档,配置下 skip 即可
请问,从单元测试能进到代码里的断点吗?
自己尝试把runtimeArgs里的dev修改为test,可以从vscode里运行单测,会出现如下提示:
dev模式,是可以直接从vscode调试进入断点的,就是不太清楚怎么通过单测进入断点。