Skip to content

require-local-test-context-for-concurrent-snapshots should detect Vitest options object concurrency #898

Description

@nami8824

Summary

require-local-test-context-for-concurrent-snapshots currently misses concurrent tests declared via Vitest's options object:

test('snapshot test', { concurrent: true }, () => {
  expect(1).toMatchSnapshot()
})

This form is currently not reported.

Since this test is concurrent, snapshot assertions should use the local Test Context expect instead of the global expect.

Reproduction

Add the following case to the invalid section of tests/require-local-test-context-for-concurrent-snapshots.test.ts.

{
  code: 'it("snapshot test", { concurrent: true }, () => { expect(1).toMatchSnapshot() })',
  errors: [{ messageId: 'requireLocalTestContext' }],
},

Then run:

pnpm test tests/require-local-test-context-for-concurrent-snapshots.test.ts

Currently, this case fails because the rule only checks the .concurrent chain form and does not recognize { concurrent: true }.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions