Skip to content

Commit

Permalink
fix: remove calls to removed fail function in tests
Browse files Browse the repository at this point in the history
Jest removed the fail function, instead errors can be thrown directly
and that will fail the test. This is hiding the actual errors that these
tests were throwing.
  • Loading branch information
jgresty committed Aug 27, 2024
1 parent faf4bf6 commit e2dbb36
Showing 1 changed file with 10 additions and 31 deletions.
41 changes: 10 additions & 31 deletions src/__tests__/lint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,26 @@ describe("lint command", () => {
it(
"can lint with path given",
async () => {
try {
await lintAction("end-end-tests/api-standards/resources");
} catch (err) {
fail(err);
}
await lintAction("end-end-tests/api-standards/resources");
},
testTimeout,
);

it(
"can lint with path and branch given",
async () => {
try {
await lintAction("end-end-tests/api-standards/resources", "main");
} catch (err) {
fail(err);
}
await lintAction("end-end-tests/api-standards/resources", "main");
},
testTimeout,
);

it(
"can lint with with --compare-to",
async () => {
try {
process.chdir("end-end-tests/api-standards");
await lintAction(undefined, undefined, {
compareTo: "HEAD",
});
} catch (err) {
fail(err);
}
process.chdir("end-end-tests/api-standards");
await lintAction(undefined, undefined, {
compareTo: "HEAD",
});
},
testTimeout,
);
Expand All @@ -61,11 +49,7 @@ describe("lint command", () => {
async () => {
// cd to location where a .vervet.yaml will be found
process.chdir("end-end-tests/api-standards");
try {
await lintAction();
} catch (err) {
fail(err);
}
await lintAction();
},
testTimeout,
);
Expand All @@ -75,11 +59,7 @@ describe("lint command", () => {
async () => {
// cd to location where a .vervet.yaml will be found
process.chdir("end-end-tests/exclusions");
try {
await lintAction();
} catch (err) {
fail(err);
}
await lintAction();
},
testTimeout,
);
Expand All @@ -91,9 +71,8 @@ describe("lint command", () => {
// a branch that should not exist
"no-such-branch-" + uuid.v4(),
);
fail("should have thrown an error");
throw new Error("should have thrown an error");
} catch (err: any) {
console.log(err);
expect(err.message).toContain("fatal: Not a valid object name");
}
});
Expand All @@ -103,7 +82,7 @@ describe("lint command", () => {
process.chdir(os.tmpdir());
try {
await lintAction();
fail("should have thrown an error");
throw new Error("should have thrown an error");
} catch (err: any) {
expect(err.message).toContain(
"cannot find .vervet.yaml -- is this a Vervet-managed API project?",
Expand Down

0 comments on commit e2dbb36

Please sign in to comment.