Testing
Unit tests
Karma + Jasmine, with specs colocated beside the code they cover
(foo.service.ts / foo.service.spec.ts). There are around 246 spec files in
src/.
$ npm test # watch mode
$ npm run test:ci # lint:quiet + headless Chrome + coverage
$ npm run test:pre-push # headless Chrome, no coverage (the pre-push hook)
$ npm run test:coverage # watch mode with coverage
Karma configuration
src/karma.conf.js
Frameworks |
|
Chrome binary |
|
Browser |
|
Random order |
Disabled ( |
Coverage output |
|
Fail fast |
|
|
Spec order is deterministic
|
src/test.ts bootstraps the environment and loads every *.spec.ts through
require.context.
Shared mocks
tests/ sits outside src/ and is reachable through the @pyb-tests/* alias.
|
A baseline auth state. |
|
Instant Advance slice state. |
|
Repayment slice state. |
|
Advance Line notification payload. |
|
LTC notification payload. |
|
Airwallex terms notification payload. |
|
|
|
|
|
|
|
Report row fixtures. |
|
Password-change service stub. |
|
Shared helpers. |
|
DOM event dispatch helper. |
In-repo mocks follow the ResourceNameMockClassType convention, e.g.
PermissionsServiceMock in
core/pyb/services/permissions.service.mock.ts.
Testing libraries
|
Component, directive, pipe and module mocking. |
|
Faster |
|
Framework and runner integration. |
|
Coverage reporting. |
|
Supplies the headless Chrome binary. |
What to test
Services with branching logic |
|
Reducers |
Pure functions with no setup — cheap and high value. |
Selectors |
Especially composed ones such as |
Effects |
Use |
Guards |
|
Flows |
|
End-to-end tests
Cypress, in cypress/.
$ npm run cypress:open
cypress.json:
{
"viewportWidth": 1200,
"viewportHeight": 800,
"env": { "environment": "stagging", "localUrl": "http://localhost:4200/" }
}
Specs
|
Authentication. |
|
Sign-in journey. |
|
Password reset. |
|
Two-factor authentication. |
|
Permission-driven visibility. |
|
Personal data access. |
Support and utilities
|
|
|
Token-based login that skips the form. |
|
|
|
Command registration. |
|
Auth helpers. |
|
App bootstrap helpers. |
|
Request interception helpers. |
|
The test user. |
The suite concentrates on authentication and permissions — the two areas where a regression is both most likely and most damaging.
|
|
Protractor
e2e/ and the metronic-e2e project in angular.json are legacy Protractor
scaffolding, superseded by Cypress.
CI
|
The test step in
The pipeline does not run tests. The Husky pre-push hook
( |
Linting
$ npm run lint # ESLint over ./src
$ npm run lint:quiet # errors only (used by test:ci)
$ npm run lint:fix
$ npm run lint:cache # content-hash cache for faster reruns
Configuration lives in .eslintrc.js, with @angular-eslint,
@typescript-eslint, eslint-plugin-import, eslint-plugin-prefer-arrow,
eslint-plugin-unused-imports and eslint-plugin-prettier.