Skip to content

Commit bb16184

Browse files
authored
chore(tests): remove temporary directories in test teardown (#666)
1 parent b0608d1 commit bb16184

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

tests/Up.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@ import {describe, beforeEach, it, expect} from 'vitest';
55
import {runCli} from './_runCli';
66

77
beforeEach(async () => {
8+
const home = await xfs.mktempPromise();
9+
810
// `process.env` is reset after each tests in setupTests.js.
9-
process.env.COREPACK_HOME = npath.fromPortablePath(await xfs.mktempPromise());
11+
process.env.COREPACK_HOME = npath.fromPortablePath(home);
1012
process.env.COREPACK_DEFAULT_TO_LATEST = `0`;
13+
14+
return async () => {
15+
await xfs.removePromise(home, {recursive: true});
16+
};
1117
});
1218

1319
describe(`UpCommand`, () => {

tests/Use.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@ import {describe, beforeEach, it, expect} from 'vitest';
55
import {runCli} from './_runCli';
66

77
beforeEach(async () => {
8+
const home = await xfs.mktempPromise();
9+
810
// `process.env` is reset after each tests in setupTests.js.
9-
process.env.COREPACK_HOME = npath.fromPortablePath(await xfs.mktempPromise());
11+
process.env.COREPACK_HOME = npath.fromPortablePath(home);
1012
process.env.COREPACK_DEFAULT_TO_LATEST = `0`;
13+
14+
return async () => {
15+
await xfs.removePromise(home, {recursive: true});
16+
};
1117
});
1218

1319
describe(`UseCommand`, () => {

0 commit comments

Comments
 (0)