Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug react tape unit test in VS code

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?

like image 498
Priyesh Tiwari Avatar asked Jul 17 '26 12:07

Priyesh Tiwari


1 Answers

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"
}
like image 71
MatteoPHRE Avatar answered Jul 20 '26 02:07

MatteoPHRE



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!