Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expect(...).resolves.toSatisfy(...) passes in the promise directly #15428

Open
goldenstein64 opened this issue Nov 26, 2024 · 1 comment
Open
Labels
bug Something isn't working bun:test Something related to the `bun test` runner confirmed bug We can reproduce this issue

Comments

@goldenstein64
Copy link

goldenstein64 commented Nov 26, 2024

What version of Bun is running?

1.1.37+8ca0eb831

What platform is your computer?

Microsoft Windows NT 10.0.22631.0 x64

What steps can reproduce the bug?

Run these tests.

import { it, expect } from "bun:test";

it("compares promise value", () => {
  expect(Promise.resolve(42)).resolves.toSatisfy((v) => v === 42);
});

it("does not compare promise instance", () => {
  const promise = Promise.resolve(10);
  expect(promise).resolves.not.toSatisfy((v) => v === promise);
});

What is the expected behavior?

Both tests should pass.

What do you see instead?

Both tests fail.

> bun test promise-satisfy.test.ts
bun test v1.1.37 (8ca0eb83)

promise-satisfy.test.ts:
1 | import { it, expect } from "bun:test";
2 | 
3 | it("compares promise value", () => {
4 |   expect(Promise.resolve(42)).resolves.toSatisfy((v) => v === 42);
                                           ^
error: expect(received).toSatisfy(expected)

Expected: [Function]
Received: Promise { <resolved> }

      at [OMITTED]\promise-satisfy.test.ts:4:40
✗ compares promise value
4 |   expect(Promise.resolve(42)).resolves.toSatisfy((v) => v === 42);
5 | });
6 | 
7 | it("does not compare promise instance", () => {
8 |   const promise = Promise.resolve(10);
9 |   expect(promise).resolves.not.toSatisfy((v) => v === promise);
                                   ^
error: expect(received).not.toSatisfy(expected)

Expected: not [Function]

      at [OMITTED]\promise-satisfy.test.ts:9:32
✗ does not compare promise instance

 0 pass
 2 fail
 2 expect() calls
Ran 2 tests across 1 files. [40.00ms]

Additional information

No response

@goldenstein64 goldenstein64 added bug Something isn't working needs triage labels Nov 26, 2024
@goldenstein64
Copy link
Author

Fixed a small typo in the reproduction, sorry!

@RiskyMH RiskyMH added bun:test Something related to the `bun test` runner confirmed bug We can reproduce this issue and removed needs triage labels Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working bun:test Something related to the `bun test` runner confirmed bug We can reproduce this issue
Projects
None yet
Development

No branches or pull requests

2 participants