Debugging Jest unit tests with breakpoints in VS Code with React Native

前端 未结 1 1574
北荒
北荒 2021-01-14 20:47

I created a React Native project using the popular Ignite CLI v2.0.0 with the default boilerplate. Then I adorned it with a bunch of nodejs shims, because I\'ll

相关标签:
1条回答
  • 2021-01-14 21:44

    Finally found the solution. It seems there are still a number of issues with the new inspector protocol in Node 8.*. In short the support for --inspect is still quite experimental.

    For example the NodeJS Inspector Manager (NiM 0.13.8) was crashing and disconnecting websocket after few second (See: NiM Github issue #17 and Chromium bug #734615).

    So I downgraded NodeJS 8.1.2 --> 7.10.1

    Now finally things work as expected. I can do all debugging in VS code, hit all the breakpoints, with the following debug configuration:

        {
            "type": "node",
            "request": "launch",
            "name": "Launch Tests",
            "program": "${workspaceRoot}/node_modules/.bin/jest",
            "args": [
                "--runInBand",
                "--no-cache"
            ],
            "runtimeArgs": [
                "--debug-brk=127.0.0.1:5858"
            ],
            "port": 5858
        }
    

    Wasted more than a day on something that should be a 5 min. no-brainer. But luckily its working now!

    0 讨论(0)
提交回复
热议问题