This repo contains the documentation, specifications and tests for the Mojaloop-PISP workstream.
- Project Documentation - Project Documentation, flows, uml diagrams and so on
- Docker-Local - Onboarding environment for local development & end to end testing
- Docker-Contract - Environment for testing with ml-testing-toolkit
Tests are run automatically by CircleCI.
# install local node modules
npm install
# start the services
cd ./docker-local
docker-compose up -d
# wait for services to be healthy
npm run wait-4-docker
# Seed the environment with test data
npm run reseed
# Run the end to end tests
npm run test:e2e
Note: You can also invoke these tests using Jest's
watch
mode:
npm run test:e2e -- --watch
# start the services
cd ./docker-contract
docker-compose up -d
npm run test:contract
Note: You can also invoke these tests using Jest's
watch
mode:
npm run test:contract -- --watch
When working on PISP features, we will follow these test guidelines:
Note: I like to refer to Martin Fowler's Testing Pyramid for testing inspiration and clarity.
-
Unit Tests - Implemented in their own repos on
pisp/*
feature branches.- use
tape
for existing repos, andjest
for new repos
- use
-
Integration Tests - Implemented in their respective repos
-
End To End Tests - Test the full end to end functionality of the PISP features. Implemented in this repository.
- End to end tests will call the HTTP endpoints of the real components + simulators to verify the end to end functionality
- use
jest
+typescript
(these are the Mojaloop Standards for new repos) and evaluate Cucumber or Gherkin jest extensions.
- Contract Tests - Test the interfaces between the Mojaloop Switch and DFSP/PISP components. Will be implemented in this repository.
- use
mojaloop-simulator
+ml-testing-toolkit
Note: Are there other contracts we need to test here? Internally, we don't do much of this type of testing. We might find that we will want contract tests between the new
auth-service
and other Mojaloop components
jest-cucumber allows to use jest
to execute Gherkin scenarios. Thanks to jest
we are getting also code coverage for BDD Scenarios.
in test/features
are Feature/Scenarios in .feature
files which contain declarations in Gherkin language.
in test/step-definitions
are Steps implementations in .step.ts
files.
Execute scenarios and report code coverage:
npm run test:bdd
Jest
setup, which allows to prepare unit tests specified in test/**/*.(spec|test).ts
files. Coverage report is always generated. If the speed of unit tests will go very slow we will refactor configuration to generate coverage only on demand.
npm run test:unit
If you want to generate test report in junit
format do:
npm run test:junit
There is mojaloop
convention to use test/unit
path to keep tests. The placement of test folder should be similar to placement of tested code in src
folder
eslint setup compatible with javascript standard and dedicated for TypeScript typescript-eslint.
- it is much more flexible
- has good support for editors to visualize linting problem during typing.
To lint all files simply run
npm run lint
Committing untested and bad formatted code to repo is bad behavior, so we use husky integrated with lint-staged.
There is defined pre-commit
hook which runs linting only for staged files, so execution time is as fast as possible - only staged files are linted and if possible automatically fixed.
Corresponding excerpt from package.json:
"husky": {
"hooks": {
"pre-commit": "lint-staged && npm run test:unit",
"post-commit": "git update-index --again"
}
},
"lint-staged": {
"*.{js,ts}": "eslint --cache --fix"
}
- Demos - End to End demos/examples
- We should maintain a simple end to end postman collection for demo and illustration purposes
- These tests can be a subset of what we implement in the
#3 End to End Tests
, and are not used to evaluate CI/CD passes or failure - For now, this should be a part of this repo, but upon the release of the PISP Features, they can be included in the
mojaloop/postman
Golden Path tests.
-
Edit
src/interface/api-template.yaml
. -
Wherever possible use snippets defined in https://github.com/mojaloop/api-snippets
-
Run
npm run build:openapi
to bundle, render and validate the generated api.