-
Notifications
You must be signed in to change notification settings - Fork 14
Front End Automated Testing
Whenever you write a component, it needs to come with a bunch of tests. Tests should be written in the front end's /test directory.
We are using Jest, Enzyme and React Testing Library.
Jest -> https://jestjs.io/en/ Enzyme -> https://airbnb.io/enzyme/docs/api/ React Testing library -> https://github.com/testing-library/react-testing-library
Jest and Enzyme documentation is really great on writing unit tests. What to test for unit tests? We want to test ui pieces and props. We don't really need to test much with unit tests.
On integrations tests we are testing changes. In order to write a good integrations test you need to think about changes. What are the crucial things that change depending on some external influence? What can I easily break in this component? What would break the application's expected behavior? Those are what you should write tests on. For integrations tests that's where the React Testing Library comes in handy. You can write integrations tests without it using just Jest and Enzyme, but React Testing Library has ways to test React Hooks, which we use.
https://medium.com/@acesmndr/testing-react-functional-components-with-hooks-using-enzyme-f732124d320a https://blog.usejournal.com/testing-with-jest-and-enzyme-in-react-part-3-best-practices-when-testing-with-jest-and-enzyme-ae3fe0c39d06 https://semaphoreci.com/community/tutorials/how-to-test-react-and-mobx-with-jest https://www.freecodecamp.org/news/testing-react-hooks/