Skip to content

Commit

Permalink
fix(tests): Replaced fail by throw Error
Browse files Browse the repository at this point in the history
It seems that fail() is broken and won't be fixed: jestjs/jest#11698
  • Loading branch information
Elscha committed Dec 14, 2023
1 parent cb09686 commit c47ed68
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/lib/pathPlanner.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
getPaths
} from "./pathPlanner";
import { CostFunction } from "./fastDownward/fdTypes";
import exp from "constants";

describe("Path Planer", () => {
// Re-usable test data (must be passed to dataHandler.init() before each test)
Expand Down Expand Up @@ -904,7 +903,7 @@ describe("Path Planer", () => {
});

if (path === null) {
fail("Path is null, but was not expected to be null");
throw new Error("Path is null, but was not expected to be null");
}

path.path = [path.path[1], path.path[0], path.path[2]];
Expand All @@ -919,7 +918,12 @@ describe("Path Planer", () => {
async (lu: LearningUnit, missingSkills: string[]) => {
switch (lu.id) {
case path.path[0].id:
fail("Must not compute any constraints for the first LU");
if (missingSkills.length > 0) {
throw new Error(
"Must not compute any constraints for the first LU"
);
}
break;
case path.path[1].id:
expect(missingSkills).toEqual(
path.path[0].teachingGoals.map(skill => skill.id)
Expand Down Expand Up @@ -960,7 +964,7 @@ describe("Path Planer", () => {
});

if (changedPath === null) {
fail("Path is null, but was not expected to be null");
throw new Error("Path is null, but was not expected to be null");
}

// Test: Verify that path has changed
Expand Down Expand Up @@ -1328,7 +1332,9 @@ function expectPath(path: Path | null, expectedPaths: string[][] | null, cost?:
}

if (!path) {
fail(`Path is null, but there was at least one path expected: ${expectedPaths[0]}`);
throw new Error(
`Path is null, but there was at least one path expected: ${expectedPaths[0]}`
);
}

const pathIds = path.path.map(lu => lu.id);
Expand Down

0 comments on commit c47ed68

Please sign in to comment.