-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: Web-specific jest tests support #8712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
11e4861 to
91fd999
Compare
tjzel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, on the second thought the extensions of the files should be .test.web.ts, not .web.test.ts to make it compliant with TypeScript resolutions #8371
tjzel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
|
You can configure your editor to pickup |
7b75a58 to
6ab6ed7
Compare

Summary
This PR adds web-specific jest setup with jsdom to allow writing tests for the web. It also includes
Platformmocking os that thePlatformno longer has to be mocked manually in tests. To create web-specific tests, we have to use the.web.test.(ts|tsx|js|jsx)extension and the test will automatically run with web APIs mocked.Note
To test components/hooks/etc. in web-specific tests, please use helpers from the
@testing-library/react, not from the@testing-library/react-nativeas the component's code is automatically transformed to the web's DOM andreact-native's matchers no longer work.Test plan
Web test to verify availability of web APIs. It can be added as the
packages/react-native-reanimated/__tests__/example.web.test.tsxfile to the project and run with jest tests to verify if everything works as expected.Test source code