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

Đang mở
#44,331 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@microsoft-playwright-automation đang làm issue này rồi.

Từ ngày 24/11/2026.

  • #44335 của @microsoft-playwright-automation — đang mở

Đánh giá

Độ khó
3/5
Thời gian dự kiến
Nửa ngày
Mức phù hợp với người mới
55/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Lĩnh vực
testing

Hướng nghiên cứu

Start by running the two-test reproduction repo; it shows the two assertions that wrongly pass. Since this is a regression between 1.56.1 and 1.64.1, bisect Playwright tags in that range to find the commit that changed how .resolves/.rejects handle a promise settling the wrong way, then read the matcher code around that diff. Done means both assertions fail with the usual 'Received promise rejected instead of resolved' and 'Received promise resolved instead of rejected' errors, the matching tests under the package's test directory pass, and .not still negates only the matcher.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

agent-triage-done
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
Ngôn ngữ chính
TypeScript
Star
100k
Fork
6.9k
Merge trung bình
16 giờ 18 phút
Pull request đã merge (30 ngày)
281

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của microsoft/playwright

Tất cả issue của microsoft/playwright

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.