Debugging Jest on VS Code

前端 未结 4 1349
北荒
北荒 2021-01-13 07:19

I\'m trying to debug Jest unit tests using VS Code. I have the following config file settings

\"configurations\": [
    {
        \"name\": \"Debug Jest Te         


        
4条回答
  •  半阙折子戏
    2021-01-13 07:54

    I am using launch.json based on https://www.basefactor.com/using-visual-studio-code-to-debug-jest-based-unit-tests article, in particular example https://github.com/Lemoncode/jest-vs-code-debugging-example/blob/master/custom-solution-jest-config-file/01-implemented/.vscode/launch.json

    The section of launch.json to debug single test (assuming that the configuration is located in ./config/test/jest.json):

    {
      "type": "node",
      "request": "launch",
      "name": "Jest debug current file",
      "program": "${workspaceFolder}/node_modules/jest/bin/jest",
      "args": [
        "${fileBasename}",
        "-c",
        "./config/test/jest.json",
        "--verbose",
        "-i",
        "--no-cache",
        //"--watchAll"
      ],
      "console": "integratedTerminal",
      "internalConsoleOptions": "neverOpen"
    }
    

提交回复
热议问题