neotest-jest icon indicating copy to clipboard operation
neotest-jest copied to clipboard

No tests matched when we run on specific test

Open samnang opened this issue 1 year ago • 1 comments

I noticed the behavior of parser to discover the position of test only supports a string in describe(string). It will not work if we have the real class name like this example below:

describe(Calculator, () => {    // <---- will not match
  it("sum a and b", () => {     // <---- run the nearest test
    expect(new Calculator().sum(1, 2)).toEqual(3);
  });
});

describe("Calculator", () => {    // <---- works
  it("sum a and b", () => {       // <---- run the nearest test
    expect(new Calculator().sum(1, 2)).toEqual(3);
  });
});

samnang avatar May 05 '23 04:05 samnang

It seems if the test or suite name isn't a singly or doubly quoted string, test detection does not work for that test/suite. Template literals and class/function references cause this issue.

I've also noticed this same issue in neotest-vitest - which seems to be based on neotest-jest.

nomnivore avatar Jul 03 '23 23:07 nomnivore