diff --git a/package.json b/package.json index cd98aecc..bab1bdf9 100644 --- a/package.json +++ b/package.json @@ -73,6 +73,7 @@ "eslint-plugin-unused-imports": "4.1.4", "husky": "9.1.7", "jest": "29.7.0", + "jest-retries": "^1.0.1", "node-mocks-http": "1.16.2", "rimraf": "6.0.1", "stryker-cli": "1.0.2", diff --git a/test/server/response-builder.test.ts b/test/server/response-builder.test.ts index a4d6c9ce..b54acefd 100644 --- a/test/server/response-builder.test.ts +++ b/test/server/response-builder.test.ts @@ -1,5 +1,6 @@ import { createResponseBuilder } from "../../src/server/response-builder.js"; import type { OpenApiOperation } from "../../src/server/types.ts"; +import retry from "jest-retries"; describe("a response builder", () => { it("starts building a response object when the status is selected", () => { @@ -135,11 +136,10 @@ describe("a response builder", () => { type: "text/plain", }); - // This assertion is flaky. The root cause seems to be JSON Schema Faker - // expect(response?.content?.[0]).toStrictEqual({ - // body: { value: "hello" }, - // type: "application/json", - // }); + expect(response?.content?.[0]).toStrictEqual({ + body: { value: "hello" }, + type: "application/json", + }); }); it("falls back to 'default' when status code is not listed explicitly", () => { @@ -227,7 +227,7 @@ describe("a response builder", () => { }, }; - it("using the status code", () => { + retry("using the status code", 10, () => { const response = createResponseBuilder(operation)[200]?.random(); expect(response?.status).toBe(200); diff --git a/yarn.lock b/yarn.lock index 00c005bd..d6d1d0ed 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7615,6 +7615,11 @@ jest-resolve@^29.7.0: resolve.exports "^2.0.0" slash "^3.0.0" +jest-retries@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/jest-retries/-/jest-retries-1.0.1.tgz#b60eac2c6f6ee7033fbc9a3cb6f3016a63b82822" + integrity sha512-tR9tCXs9+Vqw/2toQEOg+CpzOwUqReppcZH2550EnuEhw4F8TR+NbICPUJexegjN9xnuF4ABSGPgzCgAFZI0Ng== + jest-runner@^29.7.0: version "29.7.0" resolved "https://registry.yarnpkg.com/jest-runner/-/jest-runner-29.7.0.tgz#809af072d408a53dcfd2e849a4c976d3132f718e"