lundi 2 mai 2016

Typescript debugging mocha tests with VSCode

I am having problem with breakpoints in VisualStudio Code. Refer to following image of my project

enter image description here

All my tests are written inside test folder and using gulp tasks they are transpiled to build folder. The build folder looks like below enter image description here

The generated js.map has following information

{"version":3,"sources":["test/modules/subscriber/index-test.ts"],"names":[],"mappings":";...lots of js map code here","file":"test/modules/subscriber/index-test.js","sourceRoot":"..\..\..\.."}

I have configured launch.json for vs code with following

   {
        "name":"Debug mocha test",
        "request": "launch",
        "type": "node",
        "program": "${workspaceRoot}/node_modules/mocha/bin/mocha",
        "stopOnEntry": false,
        "args": ["--recursive", "build/test"],
        "runtimeArgs": [
            "--nolazy"
        ],
        "env": {
            "NODE_ENV": "development"
        },
        "externalConsole": false,
        "cwd": "${workspaceRoot}",
        "sourceMaps": true,
        "outDir": "${workspaceRoot}/build"
    }

When I launch this configuration, mocha is able to find the tests and execute it but it doesn't halt at the breakpoints specified in .ts files. I tried changing sourceRoot and other options but it simply not working.

Aucun commentaire:

Enregistrer un commentaire