nvim-neotest / neotest-jest

MIT License
121 stars 80 forks source link

BUG: Nested describe blocks use the wrong regex pattern #40

Closed benlubas closed 2 years ago

benlubas commented 2 years ago

With a testing setup such as the following:

describe('SomeClass', () => { 
  describe('aMethod', () => { 
    it('should do a', () => { 
      expect(true).toEqual(true);
    });
    it('should do b', () => { 
      expect(false).not.toBe("false");
    });
    it('should do c', () => { 
      expect({}).not.toBe(undefined);
    });
  });
});

observed behavior: Running require('neotest').run.run() from line 2 runs exactly 0 tests.

expected behavior: Running require('neotest').run.run() from line 2 should run all three tests, because they are all in the describe block.

Sticking to the example above: when running neotest.run.run() from the second line, it appears that the regex passed to jest's --testNamePattern flag is: "^aMethod". When it should be "^SomeClass aMethod" or something similar.

I would like to try and create a PR for this myself. but it might take some time. or not