oven-sh / bun

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

DOM Testing Library setup does not work in workspaces #15225

Open sebastianbuechler opened 1 week ago

sebastianbuechler commented 1 week ago

What version of Bun is running?

1.1.34+5e5e7c60f

What platform is your computer?

Microsoft Windows NT 10.0.22631.0 x64

What steps can reproduce the bug?

  1. Clone https://github.com/sebastianbuechler/Bun-Workspaces-DOM-Testing (Contains a minimal workspaces setup with one package and a setup of the Testing Library according to the Bun docs https://bun.sh/guides/test/testing-library)
  2. Open ./packages/dom.test.tsx

What is the expected behavior?

No typescript error in ./packages/dom.test.tsx as it is in the same file placed in the root ./dom.test.tsx.

What do you see instead?

Line 9 (expect(myComponent).toBeInTheDocument();) shows a typescript error: Property 'toBeInTheDocument' does not exist on type 'Matchers'.

Additional information

Is it probably just a configuration issue of workspaces?

probably-neb commented 6 days ago

I don't believe the behavior you're seeing is because of Bun, rather the Typescript LSP.

You need to tell the TS LSP to look in the workspace root for types when working in the packages/ directory. To accomplish this you can either: