Vscode-jest: Attach debugger.

Created on 8 Feb 2017  路  3Comments  路  Source: jest-community/vscode-jest

Would it be possible to attach a debugger to the tests being run? I like to set breakpoints in tests while doing TDD.

Most helpful comment

The vscode go extension adds a link above the test. It would be awesome for this plugin to do something similar where you can click on the link to run the test in debug mode.

All 3 comments

2 things:

In our repos I've been adding:

    }, {
        "name": "Run Tests With Debugger (slower, use npm run watch for normal work)",
        "type": "node",
        "request": "launch",
        "port": 5858,
        "address": "localhost",
        "stopOnEntry": false,
        "runtimeExecutable": null,
        "runtimeArgs": [
            "--debug-brk",
            "./node_modules/.bin/jest",
            "-i"
        ],
        "cwd": "${workspaceRoot}",
        "sourceMaps": true
    }]

which means normal runs are faster. Then you do debug to get it in launch mode running those tests.


When I last did serious work on this, you could only do 1 debugger at a time. So debugging tests meant killing your current session.

VS code 1.9 added multiple debugging env support, so now we could have a permanently connected debugger to the tests. Perhaps this is worth trying out.

The vscode go extension adds a link above the test. It would be awesome for this plugin to do something similar where you can click on the link to run the test in debug mode.

I'm closing it since debugging of tests has been meanwhile made available, as documented.

Was this page helpful?
0 / 5 - 0 ratings