vitest-dev / vscode

VS Code extension for Vitest
https://vitest.dev/vscode
MIT License
755 stars 85 forks source link

Regression: Duplicate describes can't be run #259

Closed ffMathy closed 7 months ago

ffMathy commented 8 months ago

Describe the bug After merging #214, a bug has been introduced for the following scenario where there are duplicate describes:

import { describe, expect, it } from 'vitest'
import { add } from '../src/add'

describe('duplicate describe', () => {
  it('test 1', () => {
    expect(add(1, 1)).toBe(2)
  })
})

describe('duplicate describe', () => {
  it('test 2', () => {
    expect(add(1, 1)).toBe(2)
  })
})

In the above scenario, you can't run "test 2". It will display a "test not found" error. This was not the case before.

To Reproduce Add the above test and try to run the "test 2" test.

Expected behavior I expected the test to be run.

Environment N/A

Additional context N/A

keroxp commented 8 months ago

This is introduced indeed by #214 but I guess it didn't work in previous version. When one case ran from vscode UI, actually both cases ran and wrong statuses were synced. This is because there're no way to distinguish those two blocks based on vitest's test results. UI is built based on the position in the file, but results have no information except their name.

ffMathy commented 8 months ago

Are you saying this is fixed by #263?

keroxp commented 8 months ago

No, I actually started it for this, but they can't resolve this. Issue still exists.

ffMathy commented 8 months ago

Ah okay. In my opinion, it's fine if both tests run. That's how it was before, and I guess also how it works when filtering with vitest directly.

sheremet-va commented 7 months ago

This should be fixed in pre-release 0.5.0 and higher. Note that the extension now requires Vitest 1.4.0 or higher.

Currently it will run both described. We can still do better - I wanted to introduce a feature to run tests in this form in Vitest itself (maybe in 1.5.0):

vitest test-file.test.js:13