Permalink
Browse files

Re-wrap async done() in try-catch (#695)

Due to facebook/jest#2059, turns out we need
those try/catch blocks I tried to remove in the previous PR.

Partially reverts #682
  • Loading branch information...
evocateur committed Mar 20, 2017
1 parent 32c5a2f commit 8c3f2df6da71cb17454cf94647ca00990927d18a
Showing with 809 additions and 586 deletions.
  1. +248 −192 test/BootstrapCommand.js
  2. +21 −6 test/ExecCommand.js
  3. +19 −11 test/ImportCommand.js
  4. +177 −122 test/InitCommand.js
  5. +314 −245 test/PublishCommand.js
  6. +30 −10 test/RunCommand.js

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -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);
}
}));
});

@@ -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);
}
}));
});

@@ -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);
}
}));
});
});
@@ -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);
}
}));
});

@@ -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);
}
}));
});

Oops, something went wrong.

0 comments on commit 8c3f2df

Please sign in to comment.