Skip to content

Frontend Tests

Dinith edited this page May 24, 2020 · 2 revisions

Testing tools used:

  • jest

    • Allows snapshot testing of React components
  • enzyme

    • Allows shallow testing of React components

Testing the React components

All React components were tested, apart from those with React.useContext() calls. We had difficulty mocking this due to its complexity. Such components are notorious for being this way. Tests were made for other components, including those using React.useHistory(). This required the following:

  • Snapshot testing using jest
  • Shallow testing using enzyme in some cases
  • Surrounding tested components that call React.useHistory() with MemoryRouter from react-router-dom