Replies: 1 comment 3 replies
-
Can you please create a code sandbox? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've been trying to migrate to
bun test
for my react project (currnently usingvitest
).But there's so little documentation on this. I followed the basic steps on https://bun.sh/docs/test/dom to set up happy-dom.
I added
happydom.ts
to mytsconfig.ts
includes
list. Which solved the eslint errors in the file.now I'm getting the following kind of error in all my tests that uses
render
:I believe this error is an issue with
bun test
, This does not happen withvitest
orjest
Here is the file where I define the render function.
Where
TestProvider
is a React component with nested providers, like a react QueryProvider & ThemeProvider. TheTestProvider
just imports Providers directly from libraries, and react.And this is where it gets quite strange, if I import the TestProvider directly in the test file and use the direct import of
render
from@testing-library/react
, the uninitialized error goes away and a new one appears.Why would window not be defined if happy-dom is loaded correctly?
My full test file looks like this:
My
./happydom.ts
file:my
bunfig.toml
file:I couldn't find any docs to help, or any repositories with a working example. Has anyone managed to migrate their
@testing-library
projects to usebun test
?I would love to see some docs on how to get it working with
@testing-library
Beta Was this translation helpful? Give feedback.
All reactions