oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
71.09k stars 2.47k forks source link

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

Open nukbal opened 1 week ago

nukbal commented 1 week ago

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