{"record":{"id":"7dc9988367d3308f","repo":"vitest-dev/vitest","slug":"expect-poll-is-not-supported-in-combination-with","errorCode":null,"errorMessage":"expect.poll() is not supported in combination with .resolves","messagePattern":"expect\\.poll\\(\\) is not supported in combination with \\.resolves","errorType":"validation","errorClass":"SyntaxError","httpStatus":null,"severity":"error","filePath":"packages/expect/src/jest-expect.ts","lineNumber":1085,"sourceCode":"  def('withContext', function (this: any, context: Record<string, any>) {\n    for (const key in context) {\n      utils.flag(this, key, context[key])\n    }\n    return this\n  })\n\n  utils.addProperty(\n    chai.Assertion.prototype,\n    'resolves',\n    function __VITEST_RESOLVES__(this: any) {\n      const error = new Error('resolves')\n      utils.flag(this, 'promise', 'resolves')\n      utils.flag(this, 'error', error)\n      const test: Test = utils.flag(this, 'vitest-test')\n      const obj = utils.flag(this, 'object')\n\n      if (utils.flag(this, 'poll')) {\n        throw new SyntaxError(\n          `expect.poll() is not supported in combination with .resolves`,\n        )\n      }\n\n      if (typeof obj?.then !== 'function') {\n        throw new TypeError(\n          `You must provide a Promise to expect() when using .resolves, not '${typeof obj}'.`,\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":1067,"sourceCodeEnd":1103,"githubUrl":"https://github.com/vitest-dev/vitest/blob/1fa9837ec26533512fdcad8baebf249771bd340a/packages/expect/src/jest-expect.ts#L1067-L1103","documentation":"`.resolves` is a Chai property that flags the assertion to wait for promise resolution. Vitest's `expect.poll()` already drives retries, and combining the two is undefined, so the code raises a `SyntaxError` before setting up the proxy. It is a usage error, not a runtime data error.","triggerScenarios":"Writing `expect.poll(() => p).resolves.toBe(...)` or chaining `.resolves` onto an assertion whose subject came from `expect.poll()`.","commonSituations":"Migrating a flaky promise test to `expect.poll` and forgetting to drop `.resolves`; copy-paste from a resolves-based test into a poll wrapper.","solutions":["Drop `.resolves` when using `expect.poll` — poll already unwraps the value via the callback.","If you need promise semantics, use `expect(promise).resolves...` without `poll`.","Return a non-promise value from the poll callback and assert directly."],"exampleFix":"// before\nexpect.poll(() => fetchResult()).resolves.toEqual(data)\n\n// after\nexpect.poll(() => fetchResult()).toEqual(data)","handlingStrategy":"validation","validationCode":"// never combine .resolves with expect.poll\n// assert directly on the polled value instead","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Drop .resolves/.rejects when adopting expect.poll.","Treat poll as the single retry mechanism for the assertion.","Lint for .resolves/.rejects chained on expect.poll in code review."],"tags":["expect","poll","resolves","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"}