From 6c9ea22c3edf3036789416ff1c59106a8b00ef02 Mon Sep 17 00:00:00 2001 From: merceyz Date: Wed, 21 Feb 2024 20:08:34 +0100 Subject: [PATCH 1/3] test: clear all `COREPACK_*` environment variables --- tests/setupTests.js | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/tests/setupTests.js b/tests/setupTests.js index cf8ca57f9..28bfbc355 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.keys(process.env) + .filter(key => key !== `FORCE_COLOR` && !key.startsWith(`COREPACK_`)) + .map(key => [key, process.env[key]]), +); switch (process.env.NOCK_ENV || ``) { case `record`: From 559c8a800e6bf636eb834902cb7cd5d2a52f9285 Mon Sep 17 00:00:00 2001 From: Kristoffer K Date: Wed, 21 Feb 2024 21:16:54 +0100 Subject: [PATCH 2/3] Update tests/setupTests.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Maƫl Nison --- tests/setupTests.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/setupTests.js b/tests/setupTests.js index 28bfbc355..b3037ac4c 100644 --- a/tests/setupTests.js +++ b/tests/setupTests.js @@ -9,9 +9,8 @@ const OLD_ENV = 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.keys(process.env) - .filter(key => key !== `FORCE_COLOR` && !key.startsWith(`COREPACK_`)) - .map(key => [key, process.env[key]]), + Object.entries(process.env) + .filter(([key]) => key !== `FORCE_COLOR` && !key.startsWith(`COREPACK_`)) ); switch (process.env.NOCK_ENV || ``) { From 500caacc9cf05c8c6dc92d00a4ee6af448f8556c Mon Sep 17 00:00:00 2001 From: merceyz Date: Wed, 21 Feb 2024 21:19:27 +0100 Subject: [PATCH 3/3] chore: format --- tests/setupTests.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/setupTests.js b/tests/setupTests.js index b3037ac4c..9b06fa1e7 100644 --- a/tests/setupTests.js +++ b/tests/setupTests.js @@ -9,8 +9,9 @@ const OLD_ENV = 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_`)) + Object.entries(process.env).filter( + ([key]) => key !== `FORCE_COLOR` && !key.startsWith(`COREPACK_`), + ), ); switch (process.env.NOCK_ENV || ``) {