Skip to content

Commit

Permalink
chore(api): add explicit helper to force fail a test when using try c…
Browse files Browse the repository at this point in the history
…atch
  • Loading branch information
cedricss committed Jan 28, 2025
1 parent 42dc8d6 commit f650a16
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
getGraphQLError,
} from "../../../../test/jestGraphqlClient";
import { graphql } from "../../../graphql/generated";
import { shouldNotGoHere } from "../../../../test/jestHelpers";

let app: FastifyInstance;

Expand Down Expand Up @@ -261,7 +262,7 @@ test("should not be able to update certification that is not in its scope", asyn
candidacy,
organism,
});
fail("an error should be thrown");
shouldNotGoHere();
} catch (error) {
const gqlError = getGraphQLError(error);
expect(gqlError).toEqual(
Expand All @@ -284,7 +285,7 @@ test("should not be able to update certification after feasibility sent", async
candidacy,
organism,
});
fail("an error should be thrown");
shouldNotGoHere();
} catch (error) {
const gqlError = getGraphQLError(error);
expect(gqlError).toEqual(
Expand Down
5 changes: 5 additions & 0 deletions packages/reva-api/test/jestHelpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const shouldNotGoHere = () => {
throw new Error(
"Ce test a échoué car la requête GraphQL n'a pas levé l'erreur attendue",
);
};

0 comments on commit f650a16

Please sign in to comment.