Karma run single test

后端 未结 9 1265
后悔当初
后悔当初 2020-11-28 11:33

I use karma for run tests. I have many tests and run all tests is very slow process. I want to run only single test in order to spend less time, because all test runs about

相关标签:
9条回答
  • 2020-11-28 12:14

    Change your karma conf to only include the test you want to run instead of a full directory.

    Inside the files : [...]

    You might want to comment the preprocessors if you need/want to debug your test in chrome to avoid having your js minified.

    0 讨论(0)
  • 2020-11-28 12:14

    Yes, this is an old thread.

    The following situation has occurred on me 2 - 3 times now in the past few years. More so when I haven't done much unit testing and have come back to it.

    I started up my Karma and found the tests, after initial start up, should have completed within 1 second to now take 20 seconds. Additionally, attempting to debug the unit tests within Chrome became tediously slow. The network tab showed all the files taking 2 - 3 seconds per file.

    Solution: I didn't realize Fiddler was open. Close it and restart your tests.

    0 讨论(0)
  • 2020-11-28 12:27

    If you are using the Karma/Jasmine stack, use:

    fdescribe("when ...", function () { // to [f]ocus on a single group of tests
      fit("should ...", function () {...}); // to [f]ocus on a single test case
    });
    

    ... and:

    xdescribe("when ...", function () { // to e[x]clude a group of tests
      xit("should ...", function () {...}); // to e[x]clude a test case
    });
    

    When you're on Karma/Mocha:

    describe.only("when ...", function () { // to run [only] this group of tests
      it.only("should ...", function () {...}); // to run [only] this test case
    });
    

    ... and:

    describe.skip("when ...", function () { // to [skip] running this group of tests
      it.skip("should ...", function () {...}); // to [skip] running this test case
    });
    
    0 讨论(0)
提交回复
热议问题