Skip to content

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

@goldenstein64

Description

@goldenstein64

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingbun:testSomething related to the `bun test` runnerconfirmed bugWe can reproduce this issue

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions