Testing¶
EUDIPLO is designed to be robust and easy to test both in development and CI environments. This guide outlines how to run, write, and automate tests for the project.
Running Tests Locally¶
To run all unit and integration tests locally:
Or with watch mode:
This uses Jest under the hood, which is configured for NestJS.
Test Coverage¶
To check code coverage:
This generates a report in the /coverage
folder. Open coverage/index.html
in
your browser to view it.
Test Structure¶
Tests are located next to their implementation files:
Use .spec.ts
naming to ensure Jest picks up the test files automatically.
Linting¶
Before pushing code, check linting rules and fix them:
GitHub Actions¶
Tests run automatically on every push to main
or pull request via GitHub
Actions.
You can find the workflow config in .github/workflows/ci.yml
.
💡 Tips¶
- Keep unit tests isolated; mock dependencies using tools like
jest.mock()
or NestJS's testing module. - For HTTP integration tests, use supertest.
- For mocking external APIs (e.g., Vault or Keycloak), consider
nock
.
Happy testing! 🚀