Skip to content

Testing

Jorge Sánchez Fernández edited this page Sep 15, 2021 · 3 revisions

Unit tests

The library used to unit test is Jest.

Unit tests are used to test domain logic, utils functions in an isolated way without access to the network.

The tests files are created under a tests directory in the parent folder to subject under test.

- src
  - data
    - {Interface}{Implementation}Repository.ts
  - domain
    - entities
      - __tests__
         - {Entity}.spec.ts
      - {Entity}.ts

To execute unit test:

$ yarn test

End to End tests

The library used to unit test is Cypress with the Cypress Testing Library plugin.

The end-to-end testing is realized in staging and production environments in the CI Build.

Cypress is used to validate the web application as a user would, interacting with the screen.

We use the Cypress Testing Library plugin to access elements in the screen because uses accessibility elements.

In this way, we test the accessibility of the web app and using accessibility elements we are creating less brittle tests because we don't use CSS selectors, etc...

To run cypress tests:

$ yarn cy:open # interactive UI
$ yarn cy:run # non-interactive UI

Clone this wiki locally