Continuous integration

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.

To add a unit test:

  1. Go to the Pipelines of the forked repository.
  1. For Repo's Dockerfile specify the
  1. In the Workflow section (at the middle of the Pipelines screen), in the Unit Test Script command line box, type npm run test.


Build and Unit Test
  1. Click Save and Build with branch master

Test Results


Test Results

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:

What’s next?