Testing
2. Client Tests
2.1. Unit Tests
Unit tests are powered by Jest and located in src/test/javascript/.
Run unit tests:
npm test
2.2. End-to-End Tests
E2E tests are powered by Cypress and located in src/test/javascript/cypress.
To run E2E tests:
-
Start Spring Boot in one terminal:
./mvnw spring-boot:run -
Run Cypress tests in another terminal:
npm run e2e
2.3. Lighthouse Audits
Run automated Lighthouse audits with cypress-audit:
npm run e2e:cypress:audits
|
Run audits only against a production-packaged build for accurate results. |
The Lighthouse report is generated at target/cypress/lhreport.html.
3. Performance Tests
Performance tests use Gatling and are written in Scala. Test files are located in src/test/java/gatling/simulations.
Run all Gatling tests:
./mvnw gatling:test
4. E2E Code Coverage
Generate code coverage reports for Cypress E2E tests:
-
Build Angular with instrumentation:
npm run webapp:instrumenter -
Start the backend (without compiling frontend):
npm run backend:start -
Run Cypress with coverage:
npm run e2e:cypress:coverage
The coverage report is generated at ./coverage/lcov-report/.
5. Code Quality with Sonar
SonarQube analyzes code quality.
5.1. Starting Sonar Server
Start a local Sonar server (accessible at http://localhost:9001):
docker compose -f src/main/docker/sonar.yml up -d
|
Forced authentication redirect is disabled in the Docker configuration for easier evaluation. Enable it for production use. |
5.2. Running Analysis
Run a Sonar analysis using the sonar-scanner or Maven plugin:
./mvnw -Pprod clean verify sonar:sonar -Dsonar.login=admin -Dsonar.password=admin
To re-run only the Sonar phase (after initial analysis):
./mvnw initialize sonar:sonar -Dsonar.login=admin -Dsonar.password=admin
|
Instead of passing credentials as CLI arguments, add them to
|
See the JHipster Code Quality page for more information.