How to debug react tape unit test in VS code

1.5k Views Asked by At

I am debugging third party library unit test. Test case is running using tape and tape-run. It is using below command to run test cases.

"test": "browserify -x react-native -x react/addons -x react/lib/ReactContext -x react/lib/ExecutionEnvironment test/index.js -t [ babelify --presets [ es2015 react ] --plugins [ transform-decorators-legacy transform-class-properties ] ] | tape-run | tap-spec"

I want to put breakpoint in vscode to debug particular test file. Do I need to use node debug along with above command to put breakpoint in vs code?

1

There are 1 best solutions below

1
On

Just put this in launch.json, and open the test specs you want to run, then hit F5. The "Program" property is the tape executable in node_modules, while ${file} passed in args is the current file you are watching in vsCode. The "console" property is used to log the test result to the vscode internalConsole.

{
        "type": "node",
        "request": "launch",
        "name": "Tape Current File",
        "program": "${workspaceFolder}\\node_modules\\tape\\bin\\tape",
        "args": [
            "${file}"
        ],
        "console": "internalConsole"
}