Running & writing tests for frontend
Before we start
If you have never run Infrahub tests before, we highly suggest following the frontend guide.
We're expecting to see proper tests for each feature/bugfix you make. If you're not sure how to write these tests, this page is made to help you get started.
Infrahub frontend has 3 types of testing:
E2E tests
Infrahub uses Playwright for e2e testing.
Folder structure
E2E tests are located in /frontend/app/tests/e2e
.
Writing e2e tests
Playwright can automatically generate tests as you perform actions in the browser, making it a quick way to start testing:
npx playwright codegen
To run a specific test, substitute test
with test.only
, or use the --grep 'test name' CLI parameter:
...
test.only('test name', async ({ page }) => {
expect(response.ok).toBe(true);
});
// or
npx playwright test --grep 'test name'
To disable a specific test, substitute test
with test.skip
:
test.skip('test name', async ({ page }) => {
expect(response.ok).toBe(true);
});