我想使用VS Code编辑和调试赛普拉斯测试。看起来这应该很简单; cypress docs mention VS Code directly(但没有提供关于如何配置VS Code的launch.json文件以便在那里或在调试页面上进行调试的线索)。我有一个启动cypress / electron的launch.json配置,但是VS Code会出现这个错误:
无法连接到运行时进程...连接ECONNREFUSED 127.0.0.1:5858
然后关闭它。
看看sample electron for VS Code project没有帮助(添加protocol
或program
属性不起作用)。
这是我的配置:
{
"name": "Start integration_tests",
"type": "node",
"request": "launch",
"stopOnEntry": false,
"cwd": "${workspaceRoot}",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/cypress",
"runtimeArgs": [
"open"
],
"console" : "internalConsole",
"port": 5858,
}
我今天设置了它,它工作了!
module.exports = (on, config) => {
on('before:browser:launch', (browser = {}, args) => {
if (browser.name === 'chrome') {
args.push('--remote-debugging-port=9222')
// whatever you return here becomes the new args
return args
}
})
}
{
"type": "chrome",
"request": "attach",
"name": "Attach to Chrome",
"port": 9222,
"urlFilter": "http://localhost:4200/*",
"webRoot": "${workspaceFolder}"
}