ms-alumnos uses Jest as its test runner for both unit tests and end-to-end (e2e) tests. Unit tests are configured through theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Distribuidos-Org/ms-alumnos/llms.txt
Use this file to discover all available pages before exploring further.
jest section inside package.json and live alongside their source files under src/. End-to-end tests use a separate configuration file at test/jest-e2e.json and live in the test/ directory.
Test scripts
The following scripts are available inpackage.json:
| Script | Command | Purpose |
|---|---|---|
yarn test | jest | Run all unit tests once |
yarn test:watch | jest --watch | Re-run unit tests on file change |
yarn test:cov | jest --coverage | Run unit tests and generate a coverage report |
yarn test:debug | node --inspect-brk … jest --runInBand | Run unit tests with the Node.js inspector attached for debugging |
yarn test:e2e | jest --config ./test/jest-e2e.json | Run end-to-end tests using the e2e Jest config |
Unit test configuration
Thejest section in package.json controls how unit tests are discovered and compiled:
rootDir: "src"— Jest searches for test files only inside thesrc/directory, keeping test discovery scoped to the application source.testRegex: ".*\\.spec\\.ts$"— any file ending in.spec.tsundersrc/is treated as a unit test file.transform—ts-jestcompiles TypeScript files on the fly so Jest can execute them directly without a separate build step.collectCoverageFrom— when running with--coverage, Jest collects coverage data from every.tsand.jsfile undersrc/.testEnvironment: "node"— tests run in a plain Node.js environment (no browser DOM simulation).
E2E test configuration
End-to-end tests use a dedicated config file attest/jest-e2e.json:
rootDir: "."— the root is set to the project root (one level abovesrc/), so Jest can locate files in thetest/directory.testRegex: ".e2e-spec.ts$"— only files ending in.e2e-spec.tsare picked up, keeping e2e and unit tests cleanly separated.
coverageDirectory — coverage collection for e2e tests is not configured by default.
Running tests with coverage
*.spec.ts file under src/, then writes an HTML and LCOV coverage report to the coverage/ directory at the project root (one level above src/, as set by coverageDirectory: "../coverage"). Open coverage/lcov-report/index.html in a browser to browse the interactive per-file breakdown.
E2E test file
The scaffolded e2e test lives attest/app.e2e-spec.ts. It bootstraps the full AppModule using NestJS’s TestingModule and uses supertest to make HTTP requests against the application:
The default e2e spec tests the HTTP layer. To add integration tests for NATS message handlers, extend this file by creating a NestJS
ClientProxy in the test setup, connecting it to the same NATS server, and sending messages via client.send({ cmd: 'your_pattern' }, payload).toPromise(). Make sure to close the client in an afterAll hook to avoid open handle warnings.