run single test case, test file or a subset of test cases in mochajs

Run a sin­gle test case

describe('Foo', () => {
  describe('#Bar()', () => {
    it.only('should execute me', () => {
      ...
    });

    it('should not execute me', () => {
      ...
    });
  });
});

Run a sin­gle test suite

describe('Foo', () => {
  describe.only('#Bar()', () => {
    ...
  });
});


Run a sub­set of suites


describe('FOO', () => { describe.only('#Bar1()', () => { it('should execute', () => { ... }); it('should execute', () => { ... }); }); describe.only('#Bar2()', () => { it('should execute 1', () => { ... }); }); describe('#Bar3()', () => { it('should NOT execute', () => { ... }); }); });


You may also like...