1. Open the debug tab
  2. Add a Chrome configuration, it'll fill out most the fields for you. For the port change it to 9876 (or whatever is specified in your karma.conf.js). See below.
  3. Set breakpoint(s) in the code you want to debug
  4. Run your the debug task which will open a chrome window to the specified port
  5. Run your test command (ng test) and refresh the opened Chrome window if necessary

Sample configuration, they are created in a filed called launch.json

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "chrome",
            "request": "launch",
            "name": "Launch Chrome against localhost",
            "url": "http://localhost:9876",
            "webRoot": "${workspaceFolder}"
        }
    ]
}
Answer from MkMan on Stack Overflow
๐ŸŒ
Visual Studio Marketplace
marketplace.visualstudio.com โ€บ items
Jasmine Test Explorer - Visual Studio Marketplace
Extension for Visual Studio Code - Run your Jasmine tests in the Sidebar of Visual Studio Code
Discussions

node.js - Debug jasmine tests written in typescript node in vs code - Stack Overflow
I have put a breakpoint in one of the test case of about.service.spec.ts but no breakpoint fired. Could anyone help me on setting up vscode debugging for jasmine tests? More on stackoverflow.com
๐ŸŒ stackoverflow.com
How to debug Jasmine tests run from Grunt in Visual Studio Code?
My unit tests are run using Karma/Jasmine through Grunt. When I run ... When opening the project in Visual Studio Code, I can run the same command using Tasks: Run Test Task. VSCode executes Grunt with the test parameter and shows the output. How can I debug the test cases that are run by VSCode ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
debugging - How to debug Unit Tests with Karma/Jasmine in Visual Studio Code? - Stack Overflow
Excellent - after struggling to get debugging in unit testing working as described in the Microsoft/vscode-recipes GitHub repo, this finally worked for me. More on stackoverflow.com
๐ŸŒ stackoverflow.com
typescript - How to run jasmine tests in visual studio code? - Stack Overflow
Created an npm task to run jasmine with node inspector inspect-brk requires node version 8 or above. You can use inspect with 7 and some versions of 6 but I was worried it might not capture my breakpoints in time and didn't investigate that option much. { /* ... */ "scripts": { "build": "tsc --project .", "test:debug... More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
Codewithdan
blog.codewithdan.com โ€บ debugging-jasmine-ts-unit-tests-in-vs-code
Debugging jasmine-ts Unit Tests in VS Code - Code with Dan Blog
October 11, 2019 - Since my unit tests were running ... unit test spec directly in VS Code, add a new debug configuration (click the gear icon in the debug pane), and add the following into the launch.json file:...
๐ŸŒ
Mcomella
mcomella.com โ€บ blog โ€บ 2024 โ€บ vscode-debugger-tsjasminenode.html
Debug Jasmine Tests in TypeScript on Node.js With VS Code | mcomella.com
This post shows you how to configure the Visual Studio Code debugger to run on Jasmine unit tests written in TypeScript using Node.js as the test runner with minimal dependencies.
๐ŸŒ
GitHub
github.com โ€บ hbenl โ€บ vscode-jasmine-test-adapter
GitHub - hbenl/vscode-jasmine-test-adapter: Jasmine Test Adapter for the VS Code Test Explorer ยท GitHub
If your tests are written in Typescript, install the ts-node npm package (if you haven't done so already) and set the jasmineExplorer.nodeArgv configuration property to ["-r", "ts-node/register"]. This is equivalent to running Jasmine with the command line ยท node -r ts-node/register ./node_modules/.bin/jasmine ยท Note that breakpoints may not work initially (this is a known limitation when debugging with ts-node in VS Code), so you may have to use debugger statements instead.
Starred by 21 users
Forked by 20 users
Languages ย  TypeScript
๐ŸŒ
Swaminathan Vetri
swaminathanvetri.in โ€บ 2017 โ€บ 04 โ€บ 07 โ€บ debugging-jasmine-unit-tests-running-with-karma-runner-in-vs-code
Debugging Jasmine Unit tests running with Karma runner in VS Code โ€“ Swaminathan Vetri
April 7, 2017 - Now, you can check all the local variables, add variables to watch, view the call stack and you can step in, step out or step over any methods and enjoy full debugging of your unit tests too. Below video shows the debugger in action. Debugging Jasmine tests in VS Code with Debugger for Chrome
Find elsewhere
Top answer
1 of 2
4

I don't think you can currently do something like node --debug-brk grunt test where test will spin up jasmine tests - since jasmine will invoke node on these spec files without the debug flag in place. I tried this and here is what I got:

node --debug-brk=3691 --nolazy ../../../usr/local/bin/grunt kftest --schema=9.2.1 --dbtype=sqlite --target=builder/properties --spec=test/builder/properties/properties-spec.js 
Debugger listening on port 3691
Running "kftest" task
>> going to run with spec:  test/builder/properties/properties-spec.js
>> command: node --debug-brk=46307 /Users/computername/project/node_modules/jasmine-node/lib/jasmine-node/cli.js test/builder/properties/properties-spec.js
Running "shell:kftest" (shell) task
Debugger listening on port 46307

This isn't too helpful since now vscode's debugger will be looking at 3691 while 46307 is not being inspected by anything - and I don't know how to tell vscode to also listen to that port.

Soooo what I ended up doing was to follow the answer posted here: Debugging jasmine-node tests with node-inspector

Basically my vscode launch.json included a config that looked like this:

{
  "name": "Jasmine-Node Debugging",
  "cwd": "${workspaceRoot}",
  "program": "${workspaceRoot}/node_modules/jasmine-node/lib/jasmine-node/cli.js",
  "request": "launch",
  "type": "node",
  "args": [
    "test/builder/properties/properties-spec.js"
  ]
}

Hope that helps.

2 of 2
2

This launch config works for me in VS Code 0.10.2:

{
    "name": "grunt",
    "type": "node",
    "request": "launch",
    "program": "/usr/local/bin/grunt",
    "args": ["test"],
    "stopOnEntry": false
}

Setting a breakpoint in my "test" task made the VS Code debugger to stop there. I had to install grunt locally (in the folder where I have the Gruntfile).

๐ŸŒ
YouTube
youtube.com โ€บ watch
My Node.js Visual Studio Code setup with Jasmine tests and debugging - YouTube
My setup for solving the Advent of Code daily challenges using Visual Studio Code, Node.js and Jasmine. Also shows how to debug node.js code with VS Code.
Published ย  December 17, 2017
๐ŸŒ
Wallabyjs
wallabyjs.com โ€บ tech โ€บ jasmine
Faster way to run, debug and view results of Jasmine tests
January 12, 2026 - Wallaby runs your JavaScript and TypeScript tests immediately as you type in VS Code, WebStorm and other editors, highlighting results next to your code.
๐ŸŒ
Zelig880
zelig880.com โ€บ home โ€บ how to debug jasmine-es6 in visual studio code
How to debug Jasmine-es6 in visual studio code - Zelig880 -
January 2, 2019 - And it turned out to be one of ... to Debug Jasmine-es6 directly in the browser, but it is possible by using the debug feature provided by Visual Studio Code....
๐ŸŒ
Visual Studio Marketplace
marketplace.visualstudio.com โ€บ items
vscode-jasmine-test-runner
Extension for Visual Studio Code - CodeLense-base jasmine test launcher
๐ŸŒ
GitHub
github.com โ€บ microsoft โ€บ vscode-js-debug โ€บ issues โ€บ 1700
Step over in Jasmine test does not pause on next line ยท Issue #1700 ยท microsoft/vscode-js-debug
May 5, 2023 - const Jasmine = require('jasmine'); const jasmine = new Jasmine(); // run it blocks sequentially jasmine.env.configure({ random: false }); debugger; jasmine.execute(['test.js']);
Author ย  c3danielxu
Top answer
1 of 2
2

The following configuration works fine for me and allow to debug jasmine tests. In your launch.json:

{
    // Name of configuration; appears in the launch configuration drop down menu.
    "name": "Launch Unit Tests",
    // Type of configuration.
    "type": "node",
    // Workspace relative or absolute path to the program.
    "program": "spec/runner.ts",
    // Automatically stop program after launch.
    "stopOnEntry": false,
    // Command line arguments passed to the program.
    "args": [],
    // Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace.
    "cwd": ".",
    // Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH.
    "runtimeExecutable": null,
    // Optional arguments passed to the runtime executable.
    "runtimeArgs": ["--nolazy"],
    // Environment variables passed to the program.
    "env": {
        "NODE_ENV": "development"
    },
    // Use JavaScript source maps (if they exist).
    "sourceMaps": true,
    // If JavaScript source maps are enabled, the generated code is expected in this directory.
    "outDir": "dist/spec",
    "request": "launch"
}

The runner.ts is as follows:

'use strict';

var Jasmine = require('jasmine');
var j = new Jasmine();

j.loadConfigFile('spec/support/jasmine.json');
j.configureDefaultReporter({
    showColors: true
});
j.execute();

The project file structure is:

-spec
--runner.ts
--support
----jasmine.json
--folderWithTests1
-dist
--spec
.....

Note - "dist" is the folder where spec ts files are built to. Therefore "outDir" is set to "dist/spec".

Hope this will help.

2 of 2
1

I've updated VS Code to 0.10.9 and Typescript to 1.8.2 and this now "just works".

๐ŸŒ
Tony Sneed's Blog
blog.tonysneed.com โ€บ 2016 โ€บ 02 โ€บ 27 โ€บ visual-studio-code-typescript-part-2
Getting Visual Studio Code Ready for TypeScript: Part 2 | Tony Sneed's Blog
March 3, 2016 - Press Cmd+Shift+D to view the Debugging pane in VS Code and select โ€œDebug Testsโ€ from the dropdown. Then set a breakpoint (pressing F9 will do the trick), and press F5 to launch the debugger.
๐ŸŒ
GitHub
github.com โ€บ mikfreedman โ€บ jasmine-webpack-vscode
GitHub - mikfreedman/jasmine-webpack-vscode: Demonstrating Jasmine tests connected to VS Code
Run and debug Jasmine tests executed using the Karma test runner, right from VS Code! Install VSCode (brew cask install visual-studio-code)
Author ย  mikfreedman