Skip to content

bun test with react DOM shows infinite error log on expect failed #10886

Closed

Description

@nukbal

What version of Bun is running?

1.1.7

What platform is your computer?

MacOS

What steps can reproduce the bug?

  1. add happy-dom, @testing-library/react
  2. add preload configuration for happy-dom
  3. run test below
import * as matchers from '@testing-library/jest-dom/matchers';
import { render, screen } from '@testing-library/react';

expect.extend(matchers);

it('test', async () => {
  render(<button>test</button>);
  expect(screen.getByRole('button')).toBeDisabled();
});

What is the expected behavior?

it could be nice to show shorter log for react element
on vitest (or jest), it shows

 FAIL  src/bun.test.tsx > test
Error: expect(element).toBeDisabled()

Received element is not disabled:
  <button />
 ❯ src/bun.test.tsx:6:38
      4|   render(<button>test</button>);
      5|
      6|   expect(screen.getByRole('button')).toBeDisabled();
       |                                      ^
      7| });
      8|

What do you see instead?

bun.test.tsx:
1 | import { render, screen } from '@testing-library/react';
2 |
3 | it('test', async () => {
4 |   render(<button>test</button>);
5 |
6 |   expect(screen.getByRole('button')).toBeDisabled();
      ^
error: expect(received).toBeDisabled()



Received element is not disabled:
  HTMLButtonElement {
  [Symbol(listeners)]: {},
  [Symbol(listenerOptions)]: {},
  [Symbol(isConnected)]: false,
  [Symbol(parentNode)]: null,
  [Symbol(rootNode)]: null,
  [Symbol(formNode)]: null,
  [Symbol(selectNode)]: null,
  [Symbol(textAreaNode)]: null,
  [Symbol(observers)]: [],
  [Symbol(childNodes)]: [],
  [Symbol(ownerDocument)]: HTMLDocument {
....

Additional information

No response

Activity

  1. added
    bug
    on May 7, 2024
  2. jjjjjjjjjjjjjjjjacob commented on Apr 21, 2025

    @jjjjjjjjjjjjjjjjacob

    I'm having this issue too, and it makes debugging more than one test at a time impossible as well as making the expected/received outputs useless. Currently using version 1.2.10.

  3. pere-seapoint commented on Jul 16, 2025

    @pere-seapoint

    Any update? This has forced us to migrate to vitest unfortunately

  4. felix-wtfoxtrot commented on Aug 21, 2025

    @felix-wtfoxtrot

    this is infuriating when trying to write tests and bun (or HappyDom?) just endlessly spams the terminal :/

    Only getting this when using toBeEnabled() or toBeDisabled() so far though.

  5. mitchlloyd commented on Oct 22, 2025

    @mitchlloyd

    Tested today with updated dependencies before starting migration to vitest:

    "@happy-dom/global-registrator": "^20.0.8",
    "@testing-library/dom": "^10.4.1",
    "@testing-library/react": "^16.3.0",
    "chalk": "^5.6.2",
    "vite": "^7.1.11",
    

    Swapped an assertion from expect(button).toBeDisabled(); to expect(button).not.toBeDisabled(); and confirmed I still get the infinite error output.

  6. removed their assignment
    on Aug 4, 2026
  7. added a commit that references this issue on Oct 20, 2026
    9b4284f
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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions