How to debug Ember addon with breakpoints in VS Code - visual-studio-code

Am trying to get breakpoints to work in VS Code with an Ember addon (version 3.18). Have tried launch.json as:
{
"version": "0.2.0",
"configurations": [
{
"type": "edge",
"request": "launch",
"name": "Launch Edge against localhost",
"port": 9222,
"runtimeArgs": [ "--remote-debugging-port=9222" ],
"url": "http://localhost:4200",
"sourceMapPathOverrides": {
"dummy/*": "${workspaceFolder}/tests/dummy/app/*",
"test-addon/*": "${workspaceFolder}/addon/*",
}
}
]}
It works fine for setting breakpoints in files in the dummy test app. But when setting a breakpoint in files within the addon folder, VSCode says "Breakpoint set but not yet bound". How can this be fixed? I assume the 2nd sourcemap path override is wrong?

After a bit of further experimenting, seems the 2nd path should be:
"addon-tree-output/test-addon/*": "${workspaceFolder}/addon/*"
Update:
Turns out this still doesn't break inside addon files correctly. eg. in an addon component file:
#action
click() {
console.log('hello') // Set breakpoint here
}
// Instead, jumps to here
Some difference between the dummy and vendor source maps perhaps? There is an option in ember-cli-build.js:
babel: {
sourceMaps: 'inline'
}
but this only applies to the dummy test app as it states in the comment underneath it?

Related

Run HTML page in Chrome

In Visual Studio Code running on Windows 10, I am trying to run a plain HTML page in Chrome using a startup script in my workspace definition. When I run the site, chrome opens to the correct URL but I get the error below stating the connection was refused. The chrome browser that opens is not the same chrome browser I use when I just browse the internet on my own. My preferences are not set and there are not any user profiles. Has anyone else experienced this behavior?
{
"folders": [
{
"path": "."
}
],
"settings": {},
"launch": {
"version": "0.2.0",
"configurations": [
{
"name": "mypage",
"request": "launch",
"type": "chrome",
"url": "http://localhost:8080/index.html",
"webRoot": "${workspaceFolder}"
}
]
}
}
I was able to run the files by changing the URL to point to the file directly. It seems even if you leave out the protocol, VS Code defaults it to HTTP. Even though my description had the HTTP URL defined, I also tried removing it. #ScottMildenburger comment got me to reevaluate that logic and find the answer. Thank you Scott!
"launch": {
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against Samples Index",
"url": "file:///${workspaceFolder}/index.html"
}
]

How can I change the capitalization of the project directory VS Code passes when debugging?

I'm running a Next.JS project in VS Code. My launch.json has the following configuration:
{
// ...
"configurations": [
{
"name": "Frontend: Dev Server",
"request": "launch",
"runtimeArgs": [
"run-script",
"dev",
"--preserve-symlinks", // To debug linked
],
"runtimeExecutable": "npm",
"skipFiles": [
"<node_internals>/**"
],
"type": "node",
}
],
}
When I run this configuration from VS Code, I get an error like the following:
C:\Program Files\nodejs\npm.cmd run-script dev --preserve-symlinks
> web-client#0.1.0 dev
> next dev -p 5555
warn - Invalid casing detected for project dir, received c:\etcetc actual path C:\etcetc, see more info here https://nextjs.org/docs/messages/invalid-project-dir-casing
I know that I want VS Code to pass in the drive letter in upper case instead of lower case, but I don't see any option to set that and I tried opening the project using code C:\etcetc directly.
How can I change the capitalization of the directory that VS Code applies to the launch configuration?
Add a current working directory to your launch.json configuration:
{
// ...
"configurations": [
{
"cwd": "${workspaceFolder}",
"name": "Frontend: Dev Server",
// ...
}
]
}
This passed an upper case drive letter to Node for me. You may also want to check that VS Code is opening the folder with the right case, i.e. node C:\etcetc.
If you still have casing errors, try deleting the .next directory.

Unbound breakpoint while debugging Karma tests in VS Code

I'm trying to debug Karma tests using VS Code. I managed to run tests and attach VS Code to the headless Chrome. The problem is that breakpoints don't work after attaching VS Code. But the "debugger" keyword works well and after stopping on it, I can set new breakpoints, and it works, but old breakpoints remain unbound.
Here are my configs:
launch.json
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "attach",
"name": "Debug Karma",
"address": "localhost",
"port": 9333,
"preLaunchTask": "Start Karma",
"trace": true,
"pathMapping": {
"/": "${workspaceRoot}/",
"/base/": "${workspaceRoot}/"
}
}
]
tasks.json
"version": "2.0.0",
"tasks": [
{
"label": "Start Karma",
"type": "npm",
"isBackground": true,
"script": "test-by-karma-dev",
"problemMatcher": [
{
"pattern": [
{
"regexp": ".",
"file": 1,
"location": 2,
"message": 3
}
],
"background": {
"activeOnStart": true,
"beginsPattern": "karma start",
"endsPattern": "Connected on socket"
}
}
]
}
]
I'm experiencing the exact same behaviour. Did you manage to solve this in the meanwhile?
I found some kind of other workaround, but it isn't any better then placing a debugger statement.
But if you press the debug button on the karma html page it opens up a new tab to /debug.html. After this attach vscode to chrome. Then the breakpoint remains bound. But the problem is that the tests have already run by then. So you have to refresh the browser tab to rerun the tests, but at that moment the breakpoint becomes unbouded again. So what you need to do is refresh the browser tab by restarting the debug session in vscode and immediately after restarting pause it.
Then remove the unbound breakpoint and place it back again. After this the breakpoint is bound. Then resume the debug session and the breakpoint gets hit.
Quite some steps and not any better than using the debugger statement, but maybe this sheds some light on the issue...

Why does R Debugger fail to verify all breakpoints (Vscode)

I am using R Debugger in Vscode to develop an RShiny app while using SSH to connect to the remote.
My launch.json file looks like this:
{
"version": "0.2.0",
"configurations": [
{
"type": "R-Debugger",
"name": "Launch R-Workspace",
"request": "launch",
"debugMode": "workspace",
"workingDirectory": "", // If I put my actual path here, it changes nothing
"allowGlobalDebugging":true
}
]
}
For the purposes of this topic, I have these folders/files:
src/www/uis
src/server.R
I set breakpoints in files within src/www/uis as well as within src/server.R.
When I use Launch R-Workspace, the breakpoints at src/www/uis will trigger but within src/server.r they turn into "unverified breakpoints".
What I've tried:
Reading through similar questions and findings answers that did not seem relevant. Reading through the documentation where I did not see anything useful to me.
Any insight?
Thanks

Debugging in VS Code using Jasmine framework (for Protractor)

I'm trying to debug in VS Code.
I've created the launch.json file:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceRoot}/conf/conf.js",
}
]
}
I'm using Jasmine and in my conf.js file (I'm using the file from the example when I installed Protractor), it starts with exports.config = { but it has 3 dots showing under it. When I click on the light bulb, it says "Convert to ES6 Module"
When I debug, it doesn't step into the code and just jumps to the end, even if I put breakdowns.
My conf.js file:
exports.config = {
directConnect: true,
capabilities: {
'browserName': 'chrome'
},
framework: 'jasmine',
specs: ['../specs/horses.js'],
jasmineNodeOpts: {
defaultTimeoutInterval: 30000
},
};
When I run: protractor .\conf\conf.js in the Terminal, it works fine.
I have a non-angular page.
Update
I misunderstood your original question so here is a config that should work. Basically the program property needs to point to protractor and you pass your conf.js using the args property
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/node_modules/protractor/bin/protractor",
"args": ["${workspaceRoot}/conf/conf.js"],
"outFiles": [ "${workspaceRoot}/out/*.js" ]
}
]
}
See this article and this previous question for more information.
Original Incorrect Ans
The config file is exporting an object and therefore only has one action that can be debugged and that is export of the config object itself. The properties you are exporting, like specs, jasmineNodeOptions are called at different times during the setup process when protractor launches and not actually doing anything at the time they are exported. If you introduced some executable code in a lifecycle hook, like a beforeLaunch or onPrepare and tried to debug that it would likely work as you are expecting