How to run a single test with Mocha?

前端 未结 12 1140
無奈伤痛
無奈伤痛 2020-12-04 05:46

I use Mocha to test my JavaScript stuff. My test file contains 5 tests. Is that possible to run a specific test (or set of tests) rather than all the tests in the file?

12条回答
  •  失恋的感觉
    2020-12-04 06:04

    You can try "it.only"

     it.only('Test one ', () => {
    
                expect(x).to.equal(y);
            });
    it('Test two ', () => {
    
                expect(x).to.equal(y);
            });
    

    in this the first one only will execute

提交回复
热议问题