'How can I pass arg "--remote-debugging-port=9229" to VS Code Extension Host in launch.json?
I want to lanuch VS Code with --remote-debugging-port.
I can do this with runTest.ts like below.
This works fine with puppereer.connect().
import { runTests } from '@vscode/test-electron';
async function main() {
try {
// The folder containing the Extension Manifest package.json
// Passed to `--extensionDevelopmentPath`
const extensionDevelopmentPath = path.resolve(__dirname, '../../');
// The path to the extension test runner script
// Passed to --extensionTestsPath
const extensionTestsPath = path.resolve(__dirname, './suite/index');
// Download VS Code, unzip it and run the integration test
await runTests({
extensionDevelopmentPath,
extensionTestsPath,
launchArgs: [
"--remote-debugging-port=9229",
]
});
} catch (err) {
console.error(err);
console.error('Failed to run tests');
process.exit(1);
}
}
main();
But when I try to do same thing with launch.json, it's failed.
When I start debug, this may cause FetchError: Failed to fetch browser webSocket URL from http://127.0.0.1:9229/json/version: request to http://127.0.0.1:9229/json/version failed, reason: connect ECONNREFUSED 127.0.0.1:9229
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension Test",
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index",
],
"runtimeArgs": [
"--remote-debugging-port=9229",
],
"outFiles": [
"${workspaceFolder}/out/test/**/*.js"
],
"preLaunchTask": "test-compile"
},
]
}
How can I do this with launch.json?
Edit:
I update my launch.json and http://127.0.0.1:9229 is now opened.
{
"args": [
"--remote-debugging-port=9229",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index",
],
"port": "9229",
}
But now, I dont get webSocketDebuggerUrl from result of fetch 127.0.0.1:9229. It only return this json.
{Browser: 'node.js/v14.16.0', Protocol-Version: '1.1'}
Solution 1:[1]
Looking at the code they have a specific location of the launchArgs
if runTests works you could try
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension Test",
"type": "extensionHost",
"request": "launch",
"args": [
"--remote-debugging-port=9229",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index",
],
"outFiles": [
"${workspaceFolder}/out/test/**/*.js"
],
"preLaunchTask": "test-compile"
},
]
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | rioV8 |
