You can optionally add the unit test to the pipeline. The unit test is a bash-like script that will run in the root of the repository, inside the Docker container, using any testing tool that supports your framework. You can either configure your unit test script within the pipeline configuration page itself. In this example, we will show how to add it within the pipeline configuration page.
Fork this example to try it. https://github.com/codefreshdemo/demochat
To add a unit test:
- Go to the Pipelines of the forked repository.
Repo's Dockerfilespecify the
- In the Workflow section (at the middle of the Pipelines screen), in the Unit Test Script command line box, type
npm run test.
Unit Tests with composition
Sometimes running unit tests require some additional services such as a Database (Mongo, MySql, Postgres etc) or third-party components like Redis, Memcache, etc. Codefresh provides you an easy way to do this by using a Codefresh pipeline and docker-compose. To run Unit Tests with a DB or other services you can create a composition and run your unit tests as part of it.
Go to Unit Tests to learn more about how to use it. Also, see how to run unit tests with composition: