This repo contains the documentation, specifications and tests for the Mojaloop-PISP workstream.
In order to generate plant uml diagrams which is a pre-commit hook, you need to have Java installed on your system. It is advised to search out how to install Java on your individual os or distro.
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
To support the wider adoption of the Third Party API and Services, we are currently translating our jest-based E2E test to TTK collections.
While this process will soon be automated and handled outside of this repo, for now, this is how you can run the e2e tests with the ttk:
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
If you want to re-run the test cases, make sure you reset the test state with:
./scripts/_reset_test_state.sh
Then run again, or run the individual test cases as you need.
# 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.
tape
for existing repos, and jest
for new reposIntegration 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.
Contract Tests - Test the interfaces between the Mojaloop Switch and DFSP/PISP components. Will be implemented in this repository.
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.
To lint all files simply run
npm run lint
husky
hookCommitting 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"
}
#3 End to End Tests
, and are not used to evaluate CI/CD passes or failuremojaloop/postman
Golden Path tests.Update the version of @mojaloop/api-snippets
in package.json
to be the latest
Edit src/interface/api-template.yaml
.
Run npm run build:openapi
to bundle, render and validate the generated apis.