lecture 17 of 190 completed

Environment variables and keeping secrets out of Git

The same suite has to run against local, staging and production-like systems, with credentials that must never reach your repository.

What you'll learn

  • How to run one suite against several environments
  • Where credentials belong, and where they must never go
  • Why a test should not know which environment it is in

A password written into a test file gets committed to your repository, and then it stays in the Git history even after someone deletes the line. This happens often, and it is not carelessness. It happens when nobody has shown you where else to put it.

This lecture is where else to put it.

The problem. Your suite has to run in more than one place. On your laptop the app is at localhost:3000. On the build server it is at a staging address. The login credentials differ too. Writing them into the test means editing tests to change environment, and it means secrets live in your repository forever.

members only

Keep reading with the full course

The Foundations track and the first 5 lectures of each framework are free. This lecture is part of the paid course, which unlocks every lecture, all three frameworks, and downloads.

See the options →