Skip to content

Debug code / test using breakpoints #901

@ConnorStroomberg

Description

@ConnorStroomberg

What problem does this feature solve?

Fix errors in your test or code under test by setting a break point and inspecting the system state.

Using the 2.x CLI combined with Karma Chrome/Firefox/... i could run a test and use the browsers build in debugger to debug de code. In the new CLI ( 3.x with jsdom) i do not see how this is done in a clean and easy to use way.

What does the proposed API look like?

yarn test --debug

Activity

yyx990803

yyx990803 commented on Feb 28, 2018

@yyx990803
Member
wangxuepeng

wangxuepeng commented on Aug 28, 2018

@wangxuepeng

Debug Jest unit test following the links works perfect:

`

{

        "type": "node",

        "request": "launch",

        "name": "Jest",

        "protocol": "inspector",

        "program": "${workspaceRoot}/node_modules/jest/bin/jest.js",

        "args": ["--runInBand"],

        "console": "integratedTerminal",

        "sourceMaps": true,

        "stopOnEntry": false

      },

`

but the same approach for mocha does not work:
`

{

        "type": "node",

        "request": "launch",

        "name": "Mocha",

        "protocol": "inspector",

        "program": "${workspaceRoot}/node_modules/mocha-webpack/bin/mocha-webpack",

        "args": [

            "--timeout",

            "999999",

            "--colors",

            "${workspaceFolder}/tests/**/*.spec.*"

        ],

        "console": "integratedTerminal",

        "sourceMaps": true,

        "stopOnEntry": false

      },

`,

it prompts error below:

_WEBPACK Failed to compile with 1 error(s)

Error in ./tests/unit/HelloWorld.spec.js

Module not found: "@/components/HelloWorld.vue" in "/Users/mkw/Dev/vue_mocha/tests/unit"

Waiting for the debugger to disconnect...
Killed: 9_

Looks like it need some webpack configuration?

BTW, I also check link feat(service): Enable inspector debugging for unit test by mocha, it seems the solution, but how to config it in VSCode?

Thanks.

LinusBorg

LinusBorg commented on Aug 28, 2018

@LinusBorg
Member

Please use forum.vuejs.org for support questions. this issue is closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @yyx990803@ConnorStroomberg@LinusBorg@wangxuepeng

        Issue actions

          Debug code / test using breakpoints · Issue #901 · vuejs/vue-cli