Skip to content

Commit

Permalink
Re-wrap async done() in try-catch
Browse files Browse the repository at this point in the history
Due to jestjs/jest#2059, turns out we need
those try/catch blocks I tried to remove in the previous PR.

Partially reverts lerna#682
  • Loading branch information
Daniel Stockman committed Mar 20, 2017
1 parent d34be78 commit b34a41d
Show file tree
Hide file tree
Showing 6 changed files with 809 additions and 586 deletions.
440 changes: 248 additions & 192 deletions test/BootstrapCommand.js

Large diffs are not rendered by default.

27 changes: 21 additions & 6 deletions test/ExecCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@ describe("ExecCommand", () => {

execCommand.runCommand(exitWithCode(0, (err) => {
if (err) return done.fail(err);
assert.equal(calls, 2);
done();

try {
assert.equal(calls, 2);
done();
} catch (ex) {
done.fail(ex);
}
}));
});

Expand Down Expand Up @@ -92,8 +97,13 @@ describe("ExecCommand", () => {

execCommand.runCommand(exitWithCode(0, (err) => {
if (err) return done.fail(err);
assert.equal(calls, 2);
done();

try {
assert.equal(calls, 2);
done();
} catch (ex) {
done.fail(ex);
}
}));
});

Expand All @@ -117,8 +127,13 @@ describe("ExecCommand", () => {

execCommand.runCommand(exitWithCode(0, (err) => {
if (err) return done.fail(err);
assert.deepEqual(ranInPackages, ["package-1"]);
done();

try {
assert.deepEqual(ranInPackages, ["package-1"]);
done();
} catch (ex) {
done.fail(ex);
}
}));
});
});
Expand Down
30 changes: 19 additions & 11 deletions test/ImportCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,19 @@ describe("ImportCommand", () => {
importCommand.runCommand(exitWithCode(0, (err) => {
if (err) return done.fail(err);

assert.ok(!pathExists.sync(path.join(testDir, "lerna-debug.log")));
try {
assert.ok(!pathExists.sync(path.join(testDir, "lerna-debug.log")));

const lastCommit = ChildProcessUtilities.execSync("git log -1 --format=\"%s\"", { cwd: testDir });
assert.equal(lastCommit, "Init external commit");
const lastCommit = ChildProcessUtilities.execSync("git log -1 --format=\"%s\"", { cwd: testDir });
assert.equal(lastCommit, "Init external commit");

const packageJson = path.join(testDir, "packages", path.basename(externalDir), "package.json");
assert.ok(pathExists.sync(packageJson));
const packageJson = path.join(testDir, "packages", path.basename(externalDir), "package.json");
assert.ok(pathExists.sync(packageJson));

done();
done();
} catch (ex) {
done.fail(ex);
}
}));
});

Expand All @@ -75,13 +79,17 @@ describe("ImportCommand", () => {
importCommand.runCommand(exitWithCode(0, (err) => {
if (err) return done.fail(err);

const lastCommit = ChildProcessUtilities.execSync("git log -1 --format=\"%s\"", { cwd: testDir });
assert.equal(lastCommit, "Moved old-file to new-file");
try {
const lastCommit = ChildProcessUtilities.execSync("git log -1 --format=\"%s\"", { cwd: testDir });
assert.equal(lastCommit, "Moved old-file to new-file");

const newFilePath = path.join(testDir, "packages", path.basename(externalDir), "new-file");
assert.ok(pathExists.sync(newFilePath));
const newFilePath = path.join(testDir, "packages", path.basename(externalDir), "new-file");
assert.ok(pathExists.sync(newFilePath));

done();
done();
} catch (ex) {
done.fail(ex);
}
}));
});

Expand Down
Loading

0 comments on commit b34a41d

Please sign in to comment.