{"record":{"id":"c09f3d593d1c6a09","repo":"vitest-dev/vitest","slug":"expect-poll-is-not-supported-in-combination-with-c09f3d","errorCode":null,"errorMessage":"expect.poll() is not supported in combination with .rejects","messagePattern":"expect\\.poll\\(\\) is not supported in combination with \\.rejects","errorType":"validation","errorClass":"SyntaxError","httpStatus":null,"severity":"error","filePath":"packages/expect/src/jest-expect.ts","lineNumber":1158,"sourceCode":"      })\n\n      return proxy\n    },\n  )\n\n  utils.addProperty(\n    chai.Assertion.prototype,\n    'rejects',\n    function __VITEST_REJECTS__(this: any) {\n      const error = new Error('rejects')\n      utils.flag(this, 'promise', 'rejects')\n      utils.flag(this, 'error', error)\n      const test: Test = utils.flag(this, 'vitest-test')\n      const obj = utils.flag(this, 'object')\n      const wrapper = typeof obj === 'function' ? obj() : obj // for jest compat\n\n      if (utils.flag(this, 'poll')) {\n        throw new SyntaxError(\n          `expect.poll() is not supported in combination with .rejects`,\n        )\n      }\n\n      if (typeof wrapper?.then !== 'function') {\n        throw new TypeError(\n          `You must provide a Promise to expect() when using .rejects, not '${typeof wrapper}'.`,\n        )\n      }\n\n      const proxy: any = new Proxy(this, {\n        get: (target, key, receiver) => {\n          const result = Reflect.get(target, key, receiver)\n\n          if (typeof result !== 'function') {\n            return result instanceof chai.Assertion ? proxy : result\n          }\n","sourceCodeStart":1140,"sourceCodeEnd":1176,"githubUrl":"https://github.com/vitest-dev/vitest/blob/1fa9837ec26533512fdcad8baebf249771bd340a/packages/expect/src/jest-expect.ts#L1140-L1176","documentation":"`.rejects` flags the assertion to expect a rejected promise. Vitest disallows pairing it with `expect.poll()` because poll already controls retry timing; chaining them is a `SyntaxError`. Thrown before any promise is inspected.","triggerScenarios":"`expect.poll(() => p).rejects.toThrow()` or any `.rejects` access on an assertion flagged with `poll`.","commonSituations":"Refactoring a `.rejects` test to use `expect.poll` without removing `.rejects`; copying a rejection pattern into a poll loop.","solutions":["Use `expect.poll(() => p).toThrow()` after letting the poll callback return the awaited rejection, or","Use `expect(p).rejects.toThrow()` without `poll` for a straightforward rejection assertion."],"exampleFix":"// before\nexpect.poll(() => failingCall()).rejects.toThrow('boom')\n\n// after\nexpect(failingCall()).rejects.toThrow('boom')","handlingStrategy":"validation","validationCode":"// never combine .rejects with expect.poll\n// use expect(p).rejects.toThrow() or poll on a sync value","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not chain .rejects onto expect.poll.","Use plain expect(p).rejects.toThrow() for rejection assertions.","Review poll-based tests to ensure no leftover .rejects modifier."],"tags":["expect","poll","rejects","syntax","jest-expect"],"backgroundTag":null,"analyzedSha":"1fa9837ec26533512fdcad8baebf249771bd340a","analyzedAt":"2026-08-11T16:11:39.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}