Is there a way to for VS Code to open a new window in Chrome instead of using existing Chrome window and opening a new tab? (I want each debug session to start off with a clean HttpContext.Session).
Here is my launch.json:
{
"name": "Development",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/bin/Debug/net7.0/Nexgen.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
},
"launchSettingsProfile": "Development"
}
I've tried the following, without any success:
Adding a "args": [ "--new-window" ] setting to my launch.json file.
Adding a new task to 'startChrome' and calling it and 'build'. It did launch a new Chrome window, but the debugger still attached to/launched in the previously running browser.
{
"label": "startChrome",
"type": "process",
"command": "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
"args": [
"--new-window",
"http://localhost:5000"
],
"problemMatcher": []
}
Adding a "commandLineArgs": "--new-instance http://localhost:7058", to my launchSettings.json file.
Solved this by setting serverReadyAction.action = debugWithChrome in launch.json.
Here is my launch.json file in VSCode:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Arquivo Atual",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"python": "${command:python.interpreterPath}",
"cwd": "${fileDirname}"
},
{
"name": "Debug Tests",
"type": "python",
"request": "test",
"console": "integratedTerminal",
"python": "${command:python.interpreterPath}", //Property python is not allowed.
"justMyCode": false
}
]
}
The commented line appears as a problem. I want to disable it, so my code have zero problems.
I believe it is a VSCode bug (already opened a issue), because it isn't marked as a problem in the first item, and if I change for the accept atribute of pythonPath the debugger does not work.
How do I disable the problem message just for this file?
I am using vscode-jest and the "debug" code lens to run individual tests. However, when running a test like this it spawns a new terminal every time. How can I prevent this by modifying the launch configuration in the launch.json file?
For reference, here is my launch.json:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"name": "vscode-jest-tests",
"request": "launch",
"args": [
"--runInBand"
],
"cwd": "${workspaceFolder}/data-utils/",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
"program": "${workspaceFolder}/data-utils/node_modules/jest/bin/jest"
}
]
}
As part of a .NET Core 2.0 project I'm starting up a .dll then launching Chrome to debug the front end via the Debugger for Chrome extension.
If I launch both manually as such:
{
"name": "[Development] Launch Server",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceRoot}/bin/Debug/netcoreapp2.0/Website.dll",
"args": [],
"cwd": "${workspaceRoot}",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart",
"env": {
"ASPNETCORE_ENVIRONMENT": "LocalDevelopment"
},
"sourceFileMap": {
"/Views": "${workspaceRoot}/Views"
}
}
and then
{
"name": "[Development] Debug Browser",
"type": "chrome",
"request": "launch",
"url": "http://localhost:5000/home",
"port": 9222,
"webRoot": "${workspaceRoot}",
"sourceMapPathOverrides": {
"webpack:///./*": "${workspaceRoot}\\*"
}
}
everything works great. However, this is a slow process because the 'Launch Server' configuration takes a few minutes to build/release and then I must manually launch 'Debug Browser'.
Ideally I would have a 'one click' solution that handles the first configuration and upon release starts up the second configuration.
I have tried:
"compounds": [
{
"name": "[Development] Launch Server & Debug Browser",
"configurations": [
"[Development] Launch Server",
"[Development] Debug Browser"
]
}
]
but this just ends up launching the first configuration and receiving this error
while the second configuration seemingly never firing off. I've looked into tasks.json but I'm not sure that's the right place for what I'm trying to accomplish.
How can I turn this into a fire and forget?
I was trying to debug Cucumber scenarios in Visual Studio code and made below changes in the launch.json.
{
"name": "e2e",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}\\node_modules\\.bin\\cucumber-js",
"stopOnEntry": false,
"args": ["--no-timeouts", "--colors"],
"cwd": "${workspaceRoot}",
"runtimeExecutable": null,
"outFiles": [
"${workspaceRoot}\\features\\step_definitions\\*.js"
]
},
However, I am not able run a debug session using the above configuration. The step def. files I created in JavaScript.
So, just need a help on the script above if that looks fine?
You could try below configuration to make your debug working in VS Code. In the outFiles give your feature file path.
{
"name": "e2e",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/node_modules/cucumber/bin/cucumber.js",
"outFiles": [
"${workspaceRoot}/features/*.feature"
]
}
============================================
UPDATE AS OF cucumber ^5.0.2:
{
"name": "NPM Cukes",
"type": "node",
"request": "launch",
"console": "integratedTerminal",
"program": "${workspaceRoot}/node_modules/cucumber/bin/cucumber-js",
"args": [
"path/to/features/**/*.feature",
"-r",
"path/to/steps/**/*",
"--tags",
"#your-tags"
]
}
If you want to debug only CURRENT feature, add this to launch.json
{
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/node_modules/.bin/cucumber-js",
"args": ["${relativeFile}"],
"name": "Cukes current",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"windows": {
"program": "${workspaceFolder}/node_modules/cucumber/bin/cucumber"
}
}
When working with Ruby, it could be used on this way to run specific feature files:
{
"name": "Cucumber",
"type": "Ruby",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}/bin/cucumber",
"args": [
"--tags", "#Mytags",
]
}
Tweaking the answer from Mukesh Rawat plus ensuring additional file paths were correct, got it working for me, :
Launch.json
{
"name": "DebugMode",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/node_modules/cucumber/bin/cucumber-js",
"args": [
"${workspaceRoot}/features/*.feature",
"--tags", "#debug"
]
}
Workspace.json
{
"cucumberautocomplete.steps": [
"features/steps/*.js"
],
"cucumberautocomplete.syncfeatures": "features/*.feature",
"cucumberautocomplete.strictGherkinCompletion": true,
"settings": {},
"folders": [
{
"path": "/Users/{me}/Documents/{project folder}/{project name}"
}
]
}
Package.json
"scripts": {
"debug": "node --inspect=1337 --debug-brk --nolazy node_modules/cucumber/bin/cucumber-js --tags #debug --format json:./reports/report.json",
CucumberTest.feature
#debug
Scenario: Validate I can get debug working
This works
{
"name": "DebugMode",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/node_modules/cucumber/bin/cucumber-js",
"args": [
"${workspaceRoot}/features/*.feature",
"--tags", "#debug"
]
}
Here's the simplest way I've found to run Cucumber.js in the VS Code debugger:
Set JavaScript debugger auto attach to "onlyWithFlag" (Ctrl+Shift+P, type "Toggle Auto Attach")
Run Cucumber.js as follows: node --inspect ./node_modules/.bin/cucumber-js <args...>
For convenience, set an NPM run script in your test project for "debug" so you can run this as npm run debug -- <args...>
with the latest Cucumber, Playwright, typescript as of January 2023 - F5 (run in VSCode) - set debugger in ts step files and use .vscode/launch.json (you might tweak your reports location)
{
"version": "0.1.0",
"configurations": [
{
"name": "debugMode",
"type": "node",
"request": "launch",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"program": "node_modules/#cucumber/cucumber/bin/cucumber-js",
"args": [
"./features/*.feature",
"--require-module",
"ts-node/register",
"--require",
"./steps/*.steps.ts",
"--tags",
"#demoX",
"--format", "progress",
"--format", "json:./Reports/cucumber_report.json"
]
}
]
}