After completing the tasks below, I successfully achieved my goal.
npm install --save-dev jasmine @types/jasmine
- Adjust
tsconfig.json
to incorporate jasmine
types globally, generate source maps, and direct all output to the dist
folder.
{
"compilerOptions": {
/* ... */
"sourceMap": true,
"outDir": "./dist",
"types": [
"node",
"jasmine"
],
/* ... */
}
}
- Established an npm task to execute jasmine with node inspector. Using
inspect-brk
requires node version 8 or above. For versions 7 and some 6 versions, you can use inspect
, but I decided not to explore this option further for fear it might not capture my breakpoints in time.
{
/* ... */
"scripts": {
"build": "tsc --project .",
"test:debug": "npm run build && node --inspect-brk node_modules/jasmine/bin/jasmine.js JASMINE_CONFIG_PATH=jasmine.json"
},
/* ... */
}
- Generated a launch task in VS Code (
launch.json
) to initiate the NPM task.
{
/* ... */
"configurations": [
/* ... */
{
"type": "node",
"request": "launch",
"name": "Run Jasmine Tests",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run-script",
"test:debug"
],
"outFiles": [
"${workspaceRoot}/dist/**.js"
],
"protocol": "inspector",
"port": 9229,
"sourceMaps": true
},
/* ... */
]
/* ... */
}
Once these steps are completed, launching the task from Visual Studio will execute your code and halt at relevant breakpoints.