Skip to content

Commit fd490b2

Browse files
travigr2m
authored andcommitted
test(tempy): handled global caching issue with globby in the npm auth test
based on learnings shared in #436 (comment). thanks @hongaar!
1 parent 23a0de7 commit fd490b2

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

test/set-npmrc-auth.test.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,28 @@ import { stub } from 'sinon';
55
import {temporaryFile, temporaryDirectory} from 'tempy';
66

77
const {HOME} = process.env;
8-
const cwd = process.cwd();
8+
const oldCwd = process.cwd();
9+
let cwd;
10+
11+
test.before((t) => {
12+
process.env.HOME = temporaryDirectory();
13+
cwd = temporaryDirectory();
14+
process.chdir(cwd);
15+
});
16+
17+
test.beforeEach(async (t) => {
18+
// Clear files
19+
await fs.remove(resolve(process.env.HOME, ".npmrc"));
20+
await fs.remove(resolve(cwd, ".npmrc"));
921

10-
test.beforeEach((t) => {
1122
// Stub the logger
1223
t.context.log = stub();
1324
t.context.logger = {log: t.context.log};
1425
});
1526

16-
test.afterEach.always(() => {
27+
test.after.always(() => {
1728
process.env.HOME = HOME;
18-
process.chdir(cwd);
29+
process.chdir(oldCwd);
1930
});
2031

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

0 commit comments

Comments
 (0)