test: clear all `COREPACK_*` environment variables (#392)

Co-authored-by: Maël Nison <nison.mael@gmail.com>
This commit is contained in:
Kristoffer K 2024-02-21 21:29:52 +01:00 committed by GitHub
parent 00506b2a15
commit 451dcf8229
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 15 deletions

View File

@ -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`: