Skip to content

Commit

Permalink
Add more notes
Browse files Browse the repository at this point in the history
  • Loading branch information
dosolkowski-work committed Oct 24, 2024
1 parent ad30170 commit 7526e33
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/App.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { App } from "App";
import { accessibilityViolationsCheck } from "testUtils";
import { accessibilityViolationsCheck } from "testUtils"; // if we import this from setupTests instead, everything breaks
import { render, screen } from "@testing-library/react";

let component: HTMLElement | undefined;
Expand Down
12 changes: 12 additions & 0 deletions src/setupTests.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
import "@testing-library/jest-dom/vitest"; // This adds jest-dom assertions such as .toBeVisible()
import * as matchers from "vitest-axe/matchers";
import { act } from "@testing-library/react";
import { axe } from "vitest-axe";

export async function accessibilityViolationsCheck(container?: HTMLElement) {
if (container) {
let axeResult;
await act(async () => {
axeResult = await axe(container);
});
expect(axeResult).toHaveNoViolations();
}
}

// Add vitest-axe toHaveNoViolations() assertion
expect.extend(matchers);
Expand Down

0 comments on commit 7526e33

Please sign in to comment.