11 Continuous integration

 

This chapter covers

  • Setting up Jenkins
  • Running both unit and E2E tests on Jenkins
  • Configuring CircleCI to run your unit and E2E tests

Writing tests for your Angular application is only half the battle. You need to remember to run those tests to make sure you catch regressions as you continue to add features. Running tests manually can be tedious. It’s better to set up a continuous integration (CI) system that will integrate with your source repository and automatically run all the tests for each change.

In practice, you develop your Protractor tests on a desktop, where you can watch the browser and see if your tests are passing. One big stumbling block people run into when setting up their tests in a CI system is that the server doesn’t normally have a GUI. (It’s a headless environment.) In this chapter, we’ll show how to set up your tests to run automatically in a headless environment. First, we’ll cover setting up your own CI system using the open source Jenkins server; then we’ll show you how easy it can be to set up testing with CircleCI, which is a hosted CI service that has a free tier.

11.1 Jenkins

Jenkins is an open source CI server with a powerful web interface. It was originally created for testing Java applications, but, thanks to a rich ecosystem of plugins, Jenkins can now test almost any project in any language. You’re going to set up a Jenkins server that will run your tests on Node.js.

11.1.1 Setting up Jenkins

11.1.2 Unit tests

11.1.3 E2E tests

11.2 CircleCI

Summary