Testing Documentation Frontend #32
archit7448
started this conversation in
General
Replies: 2 comments
-
|
Really nicely done 🚀 |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Well Detailed ✨ |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Testing Documentation
Prerequites :
Tools :
Why do we need tests ?
Folder Structure
Testing Guidelines
Often while writing tests you have some setup work that needs to happen before tests run, and you have some finishing work that needs to happen after tests run. Jest provides helper functions to handle this.(setup and teardown).
In this before Each will clear all mock before next test.
so there will be no conflict between test.
Always use
befaoreEach,beforeAllandafterEachaccording to the case.ShareButton.tsx
ShareButton.test.tsx
foo-bar-baz.js
test.js
const copyButton = screen.getByText(/copy/i);waitFor(() => expect(buttonSpy).toBeCalledTimes(1));unpredictable, slow and flaky.
beforeEach(() => { jest.useFakeTimers() })Actmethod.userEvent.click(copyButton)expect(buttonSpy).toBeCalledTimes(1))Beta Was this translation helpful? Give feedback.
All reactions