Skip to content

no-focused-tests/no-disabled-tests/warn-todo should detect Vitest options object modes #897

Description

@nami8824

Summary

no-focused-tests, no-disabled-tests, and warn-todo currently detect chained Vitest modes such as:

test.only('focused test', () => {})
test.skip('skipped test', () => {})
test.todo('todo test')

However, Vitest also supports the same modes via the options object:

test('focused test', { only: true }, () => {})
test('skipped test', { skip: true }, () => {})
test('todo test', { todo: true })

These forms are currently not reported.

Reproduction

Add the following cases to the invalid section of each rule test file.

tests/no-focused-tests.test.ts

{
  code: "test('focused test', { only: true }, () => {})",
  errors: [{ messageId: 'noFocusedTests' }],
},

tests/no-disabled-tests.test.ts

{
  code: "test('skipped test', { skip: true }, () => {})",
  errors: [{ messageId: 'disabledTest' }],
},

tests/warn-todo.test.ts

{
  code: "test('todo test', { todo: true })",
  errors: [{ messageId: 'warnTodo' }],
},

Then run:

pnpm test tests/no-focused-tests.test.ts tests/no-disabled-tests.test.ts tests/warn-todo.test.ts

Currently, these cases fail.

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