Fix test issues: Use getAllByRole for multiple elements, add React cleanup
CI Pipeline / canary (pull_request) Successful in 6s
CI Pipeline / test (20) (pull_request) Successful in 1m45s
CI Pipeline / test (18) (pull_request) Successful in 1m49s
CI Pipeline / e2e (firefox) (pull_request) Failing after 1m33s
CI Pipeline / e2e (chromium) (pull_request) Failing after 1m38s
CI Pipeline / e2e (webkit) (pull_request) Failing after 1m31s
CI Pipeline / visual-regression (pull_request) Failing after 1m56s
CI Pipeline / performance (pull_request) Failing after 1m51s
CI Pipeline / lint (pull_request) Failing after 1m14s
CI Pipeline / build (pull_request) Failing after 1m18s
CI Pipeline / storybook (pull_request) Failing after 5m58s

This commit is contained in:
adilallo
2025-08-29 22:21:28 -06:00
parent 8e0b4246b2
commit e44d7c1b92
2 changed files with 11 additions and 3 deletions
+6 -2
View File
@@ -246,13 +246,17 @@ describe("Footer", () => {
const emailLinks = screen.getAllByRole("link", {
name: "medlab@colorado.edu",
});
const blueskyLink = screen.getByRole("link", {
const blueskyLinks = screen.getAllByRole("link", {
name: "Follow us on Bluesky",
});
const gitlabLink = screen.getByRole("link", {
const gitlabLinks = screen.getAllByRole("link", {
name: "Follow us on GitLab",
});
// Use the first instance of each social media link
const blueskyLink = blueskyLinks[0];
const gitlabLink = gitlabLinks[0];
// Check email links (multiple due to responsive design)
emailLinks.forEach((emailLink) => {
expect(emailLink).toHaveClass("focus:outline-none");
+5 -1
View File
@@ -1,10 +1,14 @@
import "@testing-library/jest-dom/vitest";
import { afterAll, afterEach, beforeAll } from "vitest";
import { cleanup } from "@testing-library/react";
import { server } from "./tests/msw/server";
// expose Tailwind tokens to JSDOM (for design token checks)
import "./app/tailwind.css";
// MSW for API integration tests (mock fetch)
beforeAll(() => server.listen({ onUnhandledRequest: "bypass" }));
afterEach(() => server.resetHandlers());
afterEach(() => {
server.resetHandlers();
cleanup(); // Clean up React DOM after each test
});
afterAll(() => server.close());