firsttris / vscode-jest-runner

Simple way to run or debug one or more tests from context menu, codelens or command plalette
https://marketplace.visualstudio.com/items?itemName=firsttris.vscode-jest-runner
MIT License
264 stars 124 forks source link

Multiple tests run when I only choose one to be tested #304

Closed diego-pan closed 11 months ago

diego-pan commented 1 year ago

I'm experiencing a situation where when I choose to Run, or Debug a single test, it actually runs two tests.

For example, when I choose Debug here:

image

It will run the test I chose, and the one below it. If seems to pick up this second test based on the test description string -- since they both begin with similar text: "creates a user account".

describe('Test a module', () => {
    test('creates a user account', () => {
        // ..... test code here
    });

    test('creates a user account without an address', () => {
        // ..... test code here
    });
});

Is this by design? Is there a configuration option that I could tweak so only tests I choose are run?

hnrchrdl commented 11 months ago

I think what we would need here is to make the -t param more precise. the runner adds -t 'creates a user account', which in your example matches both test cases. maybe better would be -t '^creates a user account$'.

firsttris commented 11 months ago

i think this pull-request https://github.com/firsttris/vscode-jest-runner/pull/282 contains what you need?

hnrchrdl commented 11 months ago

i think this pull-request #282 contains what you need?

exactly