Integration tests - global-121/121-platform GitHub Wiki

What are Integration tests?

Integration tests are a type of software testing that evaluates how multiple software components work together in an application or system. They test the interactions between different modules, components, or services to ensure that they function correctly and produce the expected results.

In an integration test, the individual components are combined and tested as a group, rather than tested individually in isolation. Integration tests are often conducted after unit testing to verify that the different units or modules work correctly when integrated together.

We use a form of integration tests called API tests. API tests can be used to ensure that APIs work as expected and that they meet the specifications and requirements of the application. API tests can verify that the API functions correctly, handles inputs and outputs properly, and returns the expected results.

How to describe Integration (API) tests?

We use SuperAgent for these API tests:

https://ladjs.github.io/superagent/

How to write Integration tests

The test files can be found in the /test folder of the 121-service. You can make a new *.test.ts file to create a new test.

(The .test. part in the name is required, as this is used to 'find' all relevant files by the test-runner.)

How to run Integration tests

All configuration/set-up to run the integration-tests is contained in the Docker-container of the 121-service.
So be sure to run all commands below within the shell of the Docker-container, or prefixed with docker exec 121-service

  • To run all integration tests once: npm run test:e2e:all
  • To watch for changes on all test-files: npm run test:e2e:watch
  • To run all tests in a specific file: (in this example it will run update-pa.test.ts): npm run test:e2e:all 'update-pa'
  • Other options are in the Jest CLI docs: https://jestjs.io/docs/cli