Skip to content

[Bug]: .resolves.not and .rejects.not pass when a promise settles the wrong way #44331

Done

Description

@tolgacodes-dev

Version

1.65.1

Steps to reproduce

Clone the two-test reproduction, then run npm install and npm test. No browser installation is needed.

The two assertions are in separate tests:

await expect(Promise.reject(new Error('request failed'))).resolves.not.toBe('cached');
await expect(Promise.resolve('saved')).rejects.not.toThrow('timeout');

Expected behavior

Both tests should fail. The first promise rejects, so .resolves has no value to compare. The second fulfills, so .rejects has no rejection reason to match. Adding .not should only negate the matcher after the promise settles the expected way. This follows the documented behavior of .resolves and .rejects.

Actual behavior

The runner reports 2 passed and exits with status 0. Removing only .not from both assertions produces the expected errors: Received promise rejected instead of resolved and Received promise resolved instead of rejected.

Additional context

The same two tests fail as expected on 1.56.1. Both pass on 1.64.1, 1.65.1, and 1.66.0-alpha-2026-11-23.

Environment

OS: Debian GNU/Linux 13 (trixie), x64, Linux 6.18
Node.js: 24.22.3
npm: 11.19.1
@playwright/test: 1.65.1

Activity

  1. microsoft-playwright-automation commented on Nov 24, 2026

    @microsoft-playwright-automation
  2. microsoft-playwright-automation commented on Nov 24, 2026

    @microsoft-playwright-automation
    Contributor

    Hi, I'm the Playwright bot and I reproduced this on Linux.

    Reproduced on 1.60.0, 1.65.1, and current source (d70f422f491cfb875dd5dc05f01c61207e7382b4). Both assertions fail correctly on 1.59.1. The promise checks return a failed matcher result, which .not then turns into success. The proposed fix keeps wrong settlement and non-promise input as errors, without changing negation after the expected settlement.

    Reproduction and checks
    await expect(Promise.reject(new Error('request failed'))).resolves.not.toBe('cached');
    await expect(Promise.resolve('saved')).rejects.not.toThrow('timeout');

    These are separate tests and need no browser. Both fail on 1.59.1, but pass incorrectly on 1.60.0 and 1.65.1. Removing .not makes both fail on all three versions. Valid negated assertions, including functions returning promises, pass on all three versions and with the fix.

    On current source, the extended regression test fails without the fix and passes with it. It also checks that .resolves.not rejects non-promise input. The regression was introduced by #40301.

    With the fix: all 90 tests in the five assertion suites pass; all 834 built-in assertion checks across Chromium, Firefox, and WebKit projects pass; the build and npm run flint pass. The promise regression itself is independent of browsers.

    Draft PR: #44335

    Triaged on Linux by the Playwright bot - agent run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-triage-done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions