Skip to content

Commit

Permalink
test(tempy): handled global caching issue with globby in the npm auth…
Browse files Browse the repository at this point in the history
… test

based on learnings shared in #436 (comment). thanks @hongaar!
  • Loading branch information
travi authored and gr2m committed Jan 13, 2023
1 parent 23a0de7 commit fd490b2
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions test/set-npmrc-auth.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,28 @@ import { stub } from 'sinon';
import {temporaryFile, temporaryDirectory} from 'tempy';

const {HOME} = process.env;
const cwd = process.cwd();
const oldCwd = process.cwd();
let cwd;

test.before((t) => {
process.env.HOME = temporaryDirectory();
cwd = temporaryDirectory();
process.chdir(cwd);
});

test.beforeEach(async (t) => {
// Clear files
await fs.remove(resolve(process.env.HOME, ".npmrc"));
await fs.remove(resolve(cwd, ".npmrc"));

test.beforeEach((t) => {
// Stub the logger
t.context.log = stub();
t.context.logger = {log: t.context.log};
});

test.afterEach.always(() => {
test.after.always(() => {
process.env.HOME = HOME;
process.chdir(cwd);
process.chdir(oldCwd);
});

test.serial('Set auth with "NPM_TOKEN"', async (t) => {
Expand Down

0 comments on commit fd490b2

Please sign in to comment.