How do I debug a Jasmine spec run with Testacular (Karma)?

后端 未结 3 1367
礼貌的吻别
礼貌的吻别 2021-02-19 22:31

I have a small project with Jasmine specs and I am using Testacular as my test runner. I don\'t understand how I can debug, both the app code or the spec code. When I try to set

3条回答
  •  清酒与你
    2021-02-19 22:39

    My favorite approach to debugging tests with Karma (was Testacular) is to use this plugin:

    • https://github.com/dfederm/karma-jasmine-html-reporter

    I start up Karma like this:

    karma start karma.conf.js --browsers=Chrome --single-run=false --reporters=kjhtml
    

    This opens Karma in debug mode with a "Debug" button. When you click that, it runs all the tests in a Chrome window and shows the results as they go by. At this point you can use Developer Tools, set breakpoints, step into code etc as normal.

    Even better, you can click on a failing test and it will switch to a mode where it only runs that one test. Now you can quickly test and debug that one test without having to wait for all the others to run.

    To see this in action, here's a GitHub pull request where I added this library to our project:

    https://github.com/edx/edx-ui-toolkit/pull/12

提交回复
热议问题