Testing#
Whenever new features are implemented for WTP, we should add tests to ensure this feature still works with further changes to the code. Whenever code is merged, the tests have to be able to pass.
We have two kinds of tests:
Component Testing#
In Component testing, we can test single components isolated from the rest of the environment. To test single components, we use Vitest To run component tests, you can use
npm run test
E2E testing#
For end to end testing, we use a tool which is called cypress. To run E2E tests, we use Cypress.
To break it down, End to end testing is a type of testing that verifies the entire software application from start to finish. We implement workflows and our end to end tests ensure that they work as they should.
To run e2e tests,
npm run dev
has to be active. Then in another console run
npm run cypress
Visual testing#
To test some features, we can use Visual Testing. Visual testing is by done by capturig the program state with capturing Screenshots. Screenshots can be updated, if the desired program behaviour changes. For visual testing we use a Cypress Plugin, which lets us screenshot the whole app or single components.
cy.get(".an-element-of-your-choice").matchImage();
cy.matchImage();