Skip to content

fix(valid-expect): handle static expect APIs - #930

Merged
veritem merged 1 commit into
vitest-dev:mainfrom
w3lld1:fix/valid-expect-static-apis
Jul 10, 2026
Merged

fix(valid-expect): handle static expect APIs#930
veritem merged 1 commit into
vitest-dev:mainfrom
w3lld1:fix/valid-expect-static-apis

Conversation

@w3lld1

@w3lld1 w3lld1 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • classify expect.soft, expect.poll, and expect.element as expect APIs instead of matchers
  • validate their actual matcher chains and argument counts through the existing valid-expect logic
  • add coverage for valid chains, missing matchers, modifiers, and argument-count diagnostics

Validation

  • corepack pnpm test --run — 82 files, 2,357 tests passed
  • corepack pnpm typecheck
  • corepack pnpm lint:js
  • corepack pnpm format
  • corepack pnpm build

Local validation used Node.js 20.20.0; the repository CI matrix will additionally exercise Node.js 22 and 24 on Ubuntu and Windows.

Fixes #921
Fixes #922

@veritem veritem left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@veritem
veritem merged commit 792320a into vitest-dev:main Jul 10, 2026
5 checks passed
@dubzzz

dubzzz commented Jul 22, 2026

Copy link
Copy Markdown

Except if I'm wrong but from the official documentation of Vitest for poll, it is supposed to accept one or two parameters. Following that PR, passing two parameters to expect.poll results into an error saying Expect takes at most 1 argument - eslint vitest/valid-expect.

@julienw

julienw commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Agreed, I see the problem as well with things such as:

  await expect
    .poll(() => window.location.search, { timeout: 500 })
    .toContain("q=Grammarly");

PR: #931

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.

valid-expect should handle expect.poll and expect.element as Vitest expect APIs valid-expect should handle expect.soft as a Vitest expect API

4 participants