Skip to content

fix(no-skipped-test): detect testInfo annotations and split allowConditional - #490

Open
unlikelyzero wants to merge 2 commits into
mskelton:mainfrom
unlikelyzero:fix/no-skipped-test-testinfo
Open

fix(no-skipped-test): detect testInfo annotations and split allowConditional#490
unlikelyzero wants to merge 2 commits into
mskelton:mainfrom
unlikelyzero:fix/no-skipped-test-testinfo

Conversation

@unlikelyzero

Copy link
Copy Markdown
Collaborator

Addresses the two follow-ups raised in #446 after disallowFixme shipped in v2.10.0.

testInfo.skip() / testInfo.fixme() were not detected

The rule only inspected call chains rooted at the test identifier, so the equally valid testInfo form slipped through:

test('example test', ({}, testInfo) => {
  testInfo.skip()
  testInfo.fixme(true, 'Disabled')
})

The rule now resolves the second parameter of a test, hook, or step callback and treats annotations called on it exactly like the standalone test.skip() form — same report location, same allowConditional handling, same remove-the-statement suggestion. Annotations on the first callback parameter (the fixtures object) and on identifiers that aren't a test callback's testInfo are left alone.

Conditional skip without conditional fixme

allowConditional now accepts an object as well as a boolean:

{
  "playwright/no-skipped-test": [
    "error",
    {
      "allowConditional": { "fixme": false, "skip": true },
      "disallowFixme": true
    }
  ]
}

This is the configuration the issue asked for: conditional test.skip() stays available for tests that only run under a given configuration, while .fixme() is rejected everywhere — including conditionally — because it marks the test as failed rather than skipped.

A boolean keeps its current meaning and applies to both annotations, so { "allowConditional": true } is equivalent to { "allowConditional": { "fixme": true, "skip": true } }. No existing configuration changes behavior.

Docs updated, and tests cover the new testInfo detection (including hooks, computed accessors, and the valid non-test cases) plus both allowConditional shapes.

…onal

`testInfo.skip()` and `testInfo.fixme()` were never reported, since the
rule only looked at chains rooted at the `test` identifier. Resolve the
second parameter of a test, hook, or step callback and treat annotations
called on it the same as the standalone `test.skip()` form.

`allowConditional` now also accepts an object so `skip` and `fixme` can
be configured separately, which lets a project rely on conditional skips
while still forbidding every use of `.fixme()`. A boolean keeps working
and applies to both annotations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant