Closed mertcanaltin closed 1 year ago
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.
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 :dango:
useRouter() in a new test; I realized they need a mock
step one : added new 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 :