From 451dcf82291ccbf9d2d96b95f4bc8d33e5f8332b Mon Sep 17 00:00:00 2001 From: Kristoffer K Date: Wed, 21 Feb 2024 21:29:52 +0100 Subject: [PATCH] test: clear all `COREPACK_*` environment variables (#392) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maƫl Nison --- tests/setupTests.js | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/tests/setupTests.js b/tests/setupTests.js index cf8ca57..9b06fa1 100644 --- a/tests/setupTests.js +++ b/tests/setupTests.js @@ -6,21 +6,13 @@ const process = require(`process`); jest.retryTimes(2, {logErrorsBeforeRetry: true}); const OLD_ENV = process.env; -const { - // To ensure we test the default behavior, we must remove these env vars - // in case the local machine already set these values. - COREPACK_DEFAULT_TO_LATEST, - COREPACK_ENABLE_NETWORK, - COREPACK_ENABLE_PROJECT_SPEC, - COREPACK_ENABLE_STRICT, - COREPACK_HOME, - COREPACK_NPM_REGISTRY, - COREPACK_NPM_TOKEN, - COREPACK_NPM_USERNAME, - FORCE_COLOR, - // We save the rest to put it into `process.env` for tests. - ...processEnv -} = process.env; +// To ensure we test the default behavior, we must remove these env vars +// in case the local machine already set these values. +const processEnv = Object.fromEntries( + Object.entries(process.env).filter( + ([key]) => key !== `FORCE_COLOR` && !key.startsWith(`COREPACK_`), + ), +); switch (process.env.NOCK_ENV || ``) { case `record`: