Search code examples
jasminevisual-studio-codejasmine-node

Debugging vanilla jasmine for a node.js application in VSCode


I'm trying to run Jasmine specs on a Node.JS API using Visual Studio code. However, when I run under debug (using F5), I get no output, aside from console output which tells me it runs to some degree. If I use ctrl+F5, it runs the specs, but I of course can't break into that.

I had originally installed jasmine-node, which did work fine with some tweaking with VSCode, allowing me to run and debug tests. However, for reasons of standardization across the team, etc, etc, our other Jasmine specs in other projects are using Jasmine 2. Jasmine-Node only supports Jasmine 1, with experimental beta support for 2 on a separate branch. So I installed vanilla Jasmine as it says here that it should run fine with NodeJS.

I ran a jasmine init on the CLI and got a config file and all that good stuff. And now when I use jasmine from the command line, the specs all run. Similarly, I hooked it up to npm test and when I run that, again, all specs run.

I then thought I'd tweak the launch file to make sure we could debug our unit tests, and that's when I ran into trouble.

Here's my launch.json:

{ "type": "node", "request": "launch", "name": "Run Jasmine tests", "stopOnEntry": false, "cwd": "${workspaceRoot}/api/content", "program": "${workspaceRoot}/api/content/node_modules/jasmine/bin/jasmine.js" }

I'm using VSCode 1.14.2, with Jasmine and Jasmine-Core 2.7.

What do I need to do to get debugging to work with running tests with Jasmine? Is moving back to Jasmine-Node the best way to do this? Or is there a way to do this with vanilla Jasmine?


Solution

  • Moving to jasmine 2.8 seems to have resolved this. I also moved to jasmine-node 2.0.0, but I'm testing it and I think it's now redundant. So we may have just fallen afoul of a bug in this project.