Skip to content

Commit

Permalink
test: enforce no errors and warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmcgrath13 committed Jan 3, 2025
1 parent f501832 commit ab8f9a8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions containers/ecr-viewer/jest.setup.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import "@testing-library/jest-dom";
import { toHaveNoViolations } from "jest-axe";
import failOnConsole from "jest-fail-on-console";
import * as matchers from "jest-extended";
import { TextEncoder } from "util";
import router from "next-router-mock";
import { clearEvaluateCache } from "@/app/view-data/utils/evaluate";

global.TextEncoder = TextEncoder;

failOnConsole();

expect.extend(toHaveNoViolations);
expect.extend(matchers);

Expand Down
8 changes: 8 additions & 0 deletions containers/ecr-viewer/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions containers/ecr-viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
"jest-axe": "^8.0.0",
"jest-environment-jsdom": "^29.7.0",
"jest-extended": "^4.0.2",
"jest-fail-on-console": "^3.3.1",
"jest-fetch-mock": "^3.0.3",
"postcss": "^8.4.38",
"prettier": "3.1.1",
Expand Down
8 changes: 8 additions & 0 deletions containers/ecr-viewer/src/app/tests/component-utils.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ describe("Metrics", () => {
const basePath = "https://example.com";
const metricOptions = { key: "value" };

jest.spyOn(console, "error").mockImplementation();

await expect(metrics(basePath, metricOptions)).rejects.toThrow(
"Sorry, we couldn't find this endpoint.",
);

expect(console.error).toHaveBeenCalledOnce();
});

it("handles internal server error", async () => {
Expand All @@ -47,8 +51,12 @@ describe("Metrics", () => {
const basePath = "https://example.com";
const metricOptions = { key: "value" };

jest.spyOn(console, "error").mockImplementation();

await expect(metrics(basePath, metricOptions)).rejects.toThrow(
"Internal Server Error",
);

expect(console.error).toHaveBeenCalledOnce();
});
});

0 comments on commit ab8f9a8

Please sign in to comment.