-
Notifications
You must be signed in to change notification settings - Fork 6
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
[TESTS] it gives an error because there is no next/router mock in every new test creation #83
Comments
Hello, the reason I did this was to prevent the repetition of test code. However, now I'm starting to think if it would be reliable to run this code (jest.setup.js) in component tests that don't use useRouter(). I need some opinions on this matter fyi @kayraberktuncer @baspinarenes |
If it's a package used in certain places, it can be both code complexity and unreliable to run for each test. |
Yes, usually when we create a test and add the component to the test, if the component is using useRouter then useRouter needs to be specified as Mock For this, it seems that it would be healthier to create the test as Mock in the relevant test file, not in the jest.setup file |
Yes you are right. 💯 |
i will investigate this https://jestjs.io/docs/manual-mocks 🍡 |
useRouter() in a new test; I realized they need a mock
step one : added new test
yarn test
result :
FAIL src/modules/Dashboard/components/DomainTable/index.spec.tsx
error:
FAIL src/modules/Dashboard/components/DomainTable/index.spec.tsx
solved:
I do this in jest.setup.js instead of executing it in every test and now I can start new tests without errors
jest.setup.js :
The text was updated successfully, but these errors were encountered: