diff --git a/packages/react-scripts/config/env.js b/packages/react-scripts/config/env.js index 726db48ab5b..937076b52ba 100644 --- a/packages/react-scripts/config/env.js +++ b/packages/react-scripts/config/env.js @@ -27,9 +27,13 @@ if (!NODE_ENV) { var dotenvFiles = [ `${paths.dotenv}.${NODE_ENV}.local`, `${paths.dotenv}.${NODE_ENV}`, - `${paths.dotenv}.local`, + // Don't include `.env.local` for `test` environment + // since normally you expect tests to produce the same + // results for everyone + NODE_ENV !== 'test' && `${paths.dotenv}.local`, paths.dotenv, -]; +].filter(Boolean); + // Load environment variables from .env* files. Suppress warnings using silent // if this file is missing. dotenv will never modify any environment variables // that have already been set.