How to debug app via rake test with VSCode - ruby

Trying to debug a minitest test on a non-rails ruby application and I have the following config in the launch.json file:
{
"name": "Debug a rake task",
"type": "Ruby",
"request": "launch",
"useBundler": true,
"cwd": "${workspaceRoot}",
"showDebuggerOutput": true,
"pathToBundler": "/home/user/.rbenv/versions/2.5.5/bin/bundle",
"pathToRDebugIDE": "/home/user/.rbenv/versions/2.5.5/bin/rdebug-ide",
"program": "/home/user/.rbenv/versions/2.5.5/bin/rake",
"args": [
"test",
],
"env": {
"LOG_LEVEL": "debug",
"TEST": "test_file.rb",
"TESTOPTS": "--name=test_name",
}
},
Even though the breakpoints of the Rakefile are hit, neither the breakpoints of test_file.rb nor the breakpoints within the app are hit.
I suspect this might be because rake task are called as separate processes but I couldn't figure out how to handle this case. How can I make the debugger stop at the breakpoints of the app and the test files?
PS: I use byebug at the moment; however, it doesn't replace a IDE based debugger.

Related

VSCode run all go tests in folder with launch configuration

I'm trying to make a launch configuration that will run all of the go tests I have in a specific folder in my repo.
I can successfully run go test ./src/... in the terminal to run all the tests I care about but I'm having trouble replicating that in a VSCode launch configuration.
Here's my current launch configuration:
{
"name": "run tests",
"type": "go",
"request": "launch",
"mode": "test",
"args": ["./src..."],
"program": "${workspaceFolder}",
}
It seems that using ./src/... as args doesn't behave as I expect it to. Using this launch configuration I get an error that:
no Go files in /home/paymahn/gadic/backend
exit status 1
Process exiting with code: 1
Is there a way to replicate go test ./src/... as a VSCode launch configuration?
When I try to run a simple test I use this setting, reference here.
{
"name": "Tests",
"type": "go",
"request": "launch",
"mode": "test",
"remotePath": "",
"program": "${fileDirname}",
"env": {},
"args": ["^TestGenerateConfigurationFailure$"]
}
And about the specific folder, I understand that the Golang test tool inspects the "test" module package. No, the specific regex name folder for the Golang test tool.
You can check more info in official debugging VS-Code for Golang HERE

chrome debugs cucumber-js instead of features

I have to be able to debug cucumber features. I used the solution from here
How to debug Cucumber in Visual Studio Code (VSCode)?
I have launch.json in Visual Studio Code
{
"type": "node",
"request": "launch",
"name": "Via NPM",
"runtimeExecutable": "npm",
"windows": {
"runtimeExecutable": "npm.cmd"
},
"env":{
"NODE_PATH": "/usr/local/bin/"
},
"runtimeArgs": [
"run",
"debug"
],
"port": 5858
}
I have a script in package.json
"debug": "node --inspect-brk=5858 ./node_modules/.bin/cucumber-js -r #babel/register -r #babel/polyfill -t '#ui'"
and when I run debug from VS code, and connect to the debugger from Chrome.
Chrome debugs cucumber-js instead of my features:
I don't want to debug cucumber scripts, I want debug my features.
What did I do wrong?
If you debug next, you will debug your code

How to debug Go tests with param "./..." in VS Code

I usually run go test ./... to run all tests in my project.
How can I set up launch.json to debug every tests that normally go test ./... runs?
Assuming you're using the Go extension for VSCode:
As the vscode-go's documentation says, you could use the following:
{
"name": "Launch test package",
"type": "go",
"request": "launch",
"mode": "test",
"program": "${workspaceFolder}"
}
Note that you're specifying a new mode called "test".
You have to install delve in order to debug code using VSCode. You can install it by yourself or use the Go: Install/Update Tools command from VSCode. Read the documentation I mention first for more information.
This one should work
{
"name": "Launch test package",
"type": "go",
"request": "launch",
"mode": "test",
"program": "${workspaceFolder}/controllers"
}

While debugging protractor UI tests in Visual Studio Code breakpoints are not hit

I have an Angular 2+ project with Protractor UI tests with a layer of CucumberJS over it, thus I can define steps in Gherkin.
In Visual Studio Code I have defined launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/node_modules/protractor/bin/protractor",
"stopOnEntry": false,
"args": [
"${workspaceRoot}/protractor.conf.js"
],
"outFiles": [
"./dist/out-tsc"
]
}
],
"compounds": []
}
When I press F5 all the tests are executed and they all success, however no breakpoint is hit. On the other hand there is no problem with hitting breakpoints in WebStorm, I just point to the protractor.conf and it works.
Question: What more should I declare in launch.json to enable hitting the breakpoints in Visual Studio Code?

Can I debug my electron app whilst testing it with Spectron?

I'm running tests using Spectron, mocha and chai-as-promised. My IDE is Visual Studio Code.
I start the app from within the tests as follows:
this.app = new Application({
path: electron,
args: ['.']
});
// Then at some point I run this.app.start()
Can I connect the Visual Studio Code debugger to this application? I can run debug my test code but I need to debug the app at some point.
Yes you can debug your tests with VsCode.
For enable to debug, you should add specific configurations to launch.json like below to .
{
"name": "Debug Test Process",
"type": "node",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
"args": [
"--timeout",
"999999",
"--colors",
]
}

Resources