How do I run a single test using Jest?

后端 未结 14 1877
轮回少年
轮回少年 2020-12-12 10:22

I have a test \'works with nested children\' within the file fix-order-test.js.

Running the below runs all the tests in the file.

jest fix-order-test         


        
14条回答
  •  孤城傲影
    2020-12-12 10:41

    Jest documentation recommends the following:

    If a test is failing, one of the first things to check should be whether the test is failing when it's the only test that runs. In Jest it's simple to run only one test - just temporarily change that test command to a test.only

    test.only('this will be the only test that runs', () => {
       expect(true).toBe(false);
    });
    

    or

    it.only('this will be the only test that runs', () => {
       expect(true).toBe(false);
    });
    

提交回复
热议问题