Skip to content

Commit b63e20f

Browse files
author
Sebastian McKenzie
committed
make uninstall test resillient to intermitent failures
1 parent 7c31529 commit b63e20f

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

test/commands/install.js

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -570,26 +570,28 @@ test("uninstall should remove dependency from package.json, fbkpm.lock and node_
570570
await fs.copy(path.join(config.cwd, "fbkpm.lock"), path.join(config.cwd, "fbkpm.lock.orig"));
571571
await fs.copy(path.join(config.cwd, "package.json"), path.join(config.cwd, "package.json.orig"));
572572

573-
await uninstall(config, reporter, {}, ["dep-a"]);
573+
try {
574+
await uninstall(config, reporter, {}, ["dep-a"]);
574575

575-
assert(!await fs.exists(path.join(config.cwd, "node_modules/dep-a")));
576-
assert(await fs.exists(path.join(config.cwd, `${mirrorPath}/dep-a-1.0.0.tgz`)));
576+
assert(!await fs.exists(path.join(config.cwd, "node_modules/dep-a")));
577+
assert(await fs.exists(path.join(config.cwd, `${mirrorPath}/dep-a-1.0.0.tgz`)));
577578

578-
assert.deepEqual(
579-
JSON.parse(await fs.readFile(path.join(config.cwd, "package.json"))).dependencies,
580-
{}
581-
);
582-
583-
let lockFileContent = await fs.readFile(path.join(config.cwd, "fbkpm.lock"));
584-
let lockFileLines = lockFileContent.split("\n").filter((line) => !!line);
585-
assert.equal(lockFileLines.length, 0);
579+
assert.deepEqual(
580+
JSON.parse(await fs.readFile(path.join(config.cwd, "package.json"))).dependencies,
581+
{}
582+
);
586583

587-
await fs.unlink(path.join(config.cwd, "fbkpm.lock"));
588-
await fs.unlink(path.join(config.cwd, "package.json"));
589-
await fs.copy(path.join(config.cwd, "fbkpm.lock.orig"), path.join(config.cwd, "fbkpm.lock"));
590-
await fs.copy(path.join(config.cwd, "package.json.orig"), path.join(config.cwd, "package.json"));
591-
await fs.unlink(path.join(config.cwd, "fbkpm.lock.orig"));
592-
await fs.unlink(path.join(config.cwd, "package.json.orig"));
584+
let lockFileContent = await fs.readFile(path.join(config.cwd, "fbkpm.lock"));
585+
let lockFileLines = lockFileContent.split("\n").filter((line) => !!line);
586+
assert.equal(lockFileLines.length, 0);
587+
} finally {
588+
await fs.unlink(path.join(config.cwd, "fbkpm.lock"));
589+
await fs.unlink(path.join(config.cwd, "package.json"));
590+
await fs.copy(path.join(config.cwd, "fbkpm.lock.orig"), path.join(config.cwd, "fbkpm.lock"));
591+
await fs.copy(path.join(config.cwd, "package.json.orig"), path.join(config.cwd, "package.json"));
592+
await fs.unlink(path.join(config.cwd, "fbkpm.lock.orig"));
593+
await fs.unlink(path.join(config.cwd, "package.json.orig"));
594+
}
593595
});
594596
});
595597

0 commit comments

Comments
 (0)