From 224e079a7a4452518654915b725265d3875e7d3a Mon Sep 17 00:00:00 2001 From: Jake Jarvis Date: Sun, 12 Oct 2025 00:02:03 -0400 Subject: [PATCH] Update Vitest configuration to remove jsdom environment and add environment declarations to test files --- components/bookmarklet.test.tsx | 1 + components/create-issue-button.test.tsx | 1 + components/domain/dns-record-list.test.tsx | 1 + components/domain/domain-report-view.test.tsx | 1 + components/domain/domain-search.test.tsx | 1 + components/domain/domain-suggestions.test.tsx | 1 + components/domain/error-with-retry.test.tsx | 1 + components/domain/export-data.test.tsx | 1 + components/domain/favicon.test.tsx | 1 + components/domain/header-search.test.tsx | 1 + components/domain/key-value.test.tsx | 1 + components/domain/provider-value.test.tsx | 1 + components/domain/relative-expiry.test.tsx | 1 + components/domain/screenshot-tooltip.test.tsx | 1 + components/domain/screenshot.test.tsx | 1 + components/domain/sections/certificates-section.test.tsx | 1 + components/domain/sections/dns-records-section.test.tsx | 1 + components/domain/sections/headers-section.test.tsx | 1 + components/domain/sections/hosting-email-section.test.tsx | 1 + components/domain/sections/registration-section.test.tsx | 1 + components/domain/sections/seo-section.test.tsx | 1 + components/domain/social-preview.test.tsx | 1 + components/domain/ttl-badge.test.tsx | 1 + lib/domain.test.ts | 1 + lib/format.test.ts | 1 + lib/image.test.ts | 1 - lib/providers/detection.test.ts | 1 + lib/seo.test.ts | 1 + server/services/certificates.test.ts | 1 - server/services/hosting.test.ts | 1 - vitest.config.ts | 1 - 31 files changed, 27 insertions(+), 4 deletions(-) diff --git a/components/bookmarklet.test.tsx b/components/bookmarklet.test.tsx index 69dfc84..f71958a 100644 --- a/components/bookmarklet.test.tsx +++ b/components/bookmarklet.test.tsx @@ -1,3 +1,4 @@ +/* @vitest-environment jsdom */ import { render, screen } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; import { describe, expect, it } from "vitest"; diff --git a/components/create-issue-button.test.tsx b/components/create-issue-button.test.tsx index 954a560..c6bc7be 100644 --- a/components/create-issue-button.test.tsx +++ b/components/create-issue-button.test.tsx @@ -1,3 +1,4 @@ +/* @vitest-environment jsdom */ import { render, screen } from "@testing-library/react"; import { describe, expect, it } from "vitest"; import { CreateIssueButton } from "@/components/create-issue-button"; diff --git a/components/domain/dns-record-list.test.tsx b/components/domain/dns-record-list.test.tsx index c7be2c3..62c4eff 100644 --- a/components/domain/dns-record-list.test.tsx +++ b/components/domain/dns-record-list.test.tsx @@ -1,3 +1,4 @@ +/* @vitest-environment jsdom */ import { render, screen } from "@testing-library/react"; import { describe, expect, it, vi } from "vitest"; import { DnsRecordList } from "@/components/domain/dns-record-list"; diff --git a/components/domain/domain-report-view.test.tsx b/components/domain/domain-report-view.test.tsx index aded23c..b36b134 100644 --- a/components/domain/domain-report-view.test.tsx +++ b/components/domain/domain-report-view.test.tsx @@ -1,3 +1,4 @@ +/* @vitest-environment jsdom */ import { render, screen } from "@testing-library/react"; import { describe, expect, it, vi } from "vitest"; import { DomainReportView } from "@/components/domain/domain-report-view"; diff --git a/components/domain/domain-search.test.tsx b/components/domain/domain-search.test.tsx index 0f48f5e..da3a6c6 100644 --- a/components/domain/domain-search.test.tsx +++ b/components/domain/domain-search.test.tsx @@ -1,3 +1,4 @@ +/* @vitest-environment jsdom */ import { render, screen } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; import { beforeEach, describe, expect, it, vi } from "vitest"; diff --git a/components/domain/domain-suggestions.test.tsx b/components/domain/domain-suggestions.test.tsx index c8b63e0..35ff70c 100644 --- a/components/domain/domain-suggestions.test.tsx +++ b/components/domain/domain-suggestions.test.tsx @@ -1,3 +1,4 @@ +/* @vitest-environment jsdom */ import { render, screen } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; import { createElement } from "react"; diff --git a/components/domain/error-with-retry.test.tsx b/components/domain/error-with-retry.test.tsx index f8841ab..b53fed2 100644 --- a/components/domain/error-with-retry.test.tsx +++ b/components/domain/error-with-retry.test.tsx @@ -1,3 +1,4 @@ +/* @vitest-environment jsdom */ import { render, screen } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; import { describe, expect, it, vi } from "vitest"; diff --git a/components/domain/export-data.test.tsx b/components/domain/export-data.test.tsx index 46ab4eb..3bec166 100644 --- a/components/domain/export-data.test.tsx +++ b/components/domain/export-data.test.tsx @@ -1,3 +1,4 @@ +/* @vitest-environment jsdom */ import { describe, expect, it, vi } from "vitest"; import { exportDomainData } from "./export-data"; diff --git a/components/domain/favicon.test.tsx b/components/domain/favicon.test.tsx index e475668..79c7cb3 100644 --- a/components/domain/favicon.test.tsx +++ b/components/domain/favicon.test.tsx @@ -1,3 +1,4 @@ +/* @vitest-environment jsdom */ import { render, screen } from "@testing-library/react"; import { createElement } from "react"; import type { Mock } from "vitest"; diff --git a/components/domain/header-search.test.tsx b/components/domain/header-search.test.tsx index 8da90fd..abb38d5 100644 --- a/components/domain/header-search.test.tsx +++ b/components/domain/header-search.test.tsx @@ -1,3 +1,4 @@ +/* @vitest-environment jsdom */ import { render, screen, waitFor } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; import { beforeEach, describe, expect, it, vi } from "vitest"; diff --git a/components/domain/key-value.test.tsx b/components/domain/key-value.test.tsx index 14e269f..9a79729 100644 --- a/components/domain/key-value.test.tsx +++ b/components/domain/key-value.test.tsx @@ -1,3 +1,4 @@ +/* @vitest-environment jsdom */ import { render, screen } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; diff --git a/components/domain/provider-value.test.tsx b/components/domain/provider-value.test.tsx index 397c9af..e032c0e 100644 --- a/components/domain/provider-value.test.tsx +++ b/components/domain/provider-value.test.tsx @@ -1,3 +1,4 @@ +/* @vitest-environment jsdom */ import { render, screen } from "@testing-library/react"; import { describe, expect, it, vi } from "vitest"; import { ProviderValue } from "./provider-value"; diff --git a/components/domain/relative-expiry.test.tsx b/components/domain/relative-expiry.test.tsx index 62f748d..389fdc6 100644 --- a/components/domain/relative-expiry.test.tsx +++ b/components/domain/relative-expiry.test.tsx @@ -1,3 +1,4 @@ +/* @vitest-environment jsdom */ import { render, screen, waitFor } from "@testing-library/react"; import { describe, expect, it } from "vitest"; import { RelativeExpiry } from "./relative-expiry"; diff --git a/components/domain/screenshot-tooltip.test.tsx b/components/domain/screenshot-tooltip.test.tsx index d85c443..3610205 100644 --- a/components/domain/screenshot-tooltip.test.tsx +++ b/components/domain/screenshot-tooltip.test.tsx @@ -1,3 +1,4 @@ +/* @vitest-environment jsdom */ import { fireEvent, render, screen } from "@testing-library/react"; import type { Mock } from "vitest"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; diff --git a/components/domain/screenshot.test.tsx b/components/domain/screenshot.test.tsx index 6d43002..8ec1deb 100644 --- a/components/domain/screenshot.test.tsx +++ b/components/domain/screenshot.test.tsx @@ -1,3 +1,4 @@ +/* @vitest-environment jsdom */ import { render, screen } from "@testing-library/react"; import { createElement } from "react"; import type { Mock } from "vitest"; diff --git a/components/domain/sections/certificates-section.test.tsx b/components/domain/sections/certificates-section.test.tsx index 0eb56d1..9455f08 100644 --- a/components/domain/sections/certificates-section.test.tsx +++ b/components/domain/sections/certificates-section.test.tsx @@ -1,3 +1,4 @@ +/* @vitest-environment jsdom */ import { render, screen } from "@testing-library/react"; import { describe, expect, it, vi } from "vitest"; import { CertificatesSection, equalHostname } from "./certificates-section"; diff --git a/components/domain/sections/dns-records-section.test.tsx b/components/domain/sections/dns-records-section.test.tsx index 1d420f9..e45de63 100644 --- a/components/domain/sections/dns-records-section.test.tsx +++ b/components/domain/sections/dns-records-section.test.tsx @@ -1,3 +1,4 @@ +/* @vitest-environment jsdom */ import { render, screen } from "@testing-library/react"; import { describe, expect, it, vi } from "vitest"; import { DnsRecordsSection } from "./dns-records-section"; diff --git a/components/domain/sections/headers-section.test.tsx b/components/domain/sections/headers-section.test.tsx index 38f68bd..fd75565 100644 --- a/components/domain/sections/headers-section.test.tsx +++ b/components/domain/sections/headers-section.test.tsx @@ -1,3 +1,4 @@ +/* @vitest-environment jsdom */ import { render, screen } from "@testing-library/react"; import { describe, expect, it, vi } from "vitest"; import { HeadersSection } from "./headers-section"; diff --git a/components/domain/sections/hosting-email-section.test.tsx b/components/domain/sections/hosting-email-section.test.tsx index 325a84a..f8f3571 100644 --- a/components/domain/sections/hosting-email-section.test.tsx +++ b/components/domain/sections/hosting-email-section.test.tsx @@ -1,3 +1,4 @@ +/* @vitest-environment jsdom */ import { render, screen } from "@testing-library/react"; import { describe, expect, it, vi } from "vitest"; import { HostingEmailSection } from "./hosting-email-section"; diff --git a/components/domain/sections/registration-section.test.tsx b/components/domain/sections/registration-section.test.tsx index 0e3ab26..64b1d9f 100644 --- a/components/domain/sections/registration-section.test.tsx +++ b/components/domain/sections/registration-section.test.tsx @@ -1,3 +1,4 @@ +/* @vitest-environment jsdom */ import { render, screen } from "@testing-library/react"; import { describe, expect, it, vi } from "vitest"; import { formatRegistrant, RegistrationSection } from "./registration-section"; diff --git a/components/domain/sections/seo-section.test.tsx b/components/domain/sections/seo-section.test.tsx index fdd4d80..451fbe5 100644 --- a/components/domain/sections/seo-section.test.tsx +++ b/components/domain/sections/seo-section.test.tsx @@ -1,3 +1,4 @@ +/* @vitest-environment jsdom */ import { render, screen } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; import { createElement } from "react"; diff --git a/components/domain/social-preview.test.tsx b/components/domain/social-preview.test.tsx index 0098a63..4a220ad 100644 --- a/components/domain/social-preview.test.tsx +++ b/components/domain/social-preview.test.tsx @@ -1,3 +1,4 @@ +/* @vitest-environment jsdom */ import { render, screen } from "@testing-library/react"; import { createElement } from "react"; import { describe, expect, it, vi } from "vitest"; diff --git a/components/domain/ttl-badge.test.tsx b/components/domain/ttl-badge.test.tsx index bf30a96..f96bf1e 100644 --- a/components/domain/ttl-badge.test.tsx +++ b/components/domain/ttl-badge.test.tsx @@ -1,3 +1,4 @@ +/* @vitest-environment jsdom */ import { render, screen } from "@testing-library/react"; import { describe, expect, it, vi } from "vitest"; import { TtlBadge } from "./ttl-badge"; diff --git a/lib/domain.test.ts b/lib/domain.test.ts index 8859abe..9658ebb 100644 --- a/lib/domain.test.ts +++ b/lib/domain.test.ts @@ -1,3 +1,4 @@ +/* @vitest-environment node */ import { describe, expect, it } from "vitest"; import { isValidDomain, normalizeDomainInput } from "./domain"; diff --git a/lib/format.test.ts b/lib/format.test.ts index 5ccf9fd..dbc9fea 100644 --- a/lib/format.test.ts +++ b/lib/format.test.ts @@ -1,3 +1,4 @@ +/* @vitest-environment node */ import { describe, expect, it } from "vitest"; import { formatDate, formatTtl } from "./format"; diff --git a/lib/image.test.ts b/lib/image.test.ts index 5bee271..cb3c41b 100644 --- a/lib/image.test.ts +++ b/lib/image.test.ts @@ -1,5 +1,4 @@ /* @vitest-environment node */ - import sharp from "sharp"; import { describe, expect, it } from "vitest"; import { diff --git a/lib/providers/detection.test.ts b/lib/providers/detection.test.ts index 6586c54..8aef810 100644 --- a/lib/providers/detection.test.ts +++ b/lib/providers/detection.test.ts @@ -1,3 +1,4 @@ +/* @vitest-environment node */ import { describe, expect, it } from "vitest"; import { detectCertificateAuthority, diff --git a/lib/seo.test.ts b/lib/seo.test.ts index 7d37531..1c0a6eb 100644 --- a/lib/seo.test.ts +++ b/lib/seo.test.ts @@ -1,3 +1,4 @@ +/* @vitest-environment node */ import { describe, expect, it } from "vitest"; import { parseHtmlMeta, diff --git a/server/services/certificates.test.ts b/server/services/certificates.test.ts index 9420a31..3a9abff 100644 --- a/server/services/certificates.test.ts +++ b/server/services/certificates.test.ts @@ -1,5 +1,4 @@ /* @vitest-environment node */ - import type * as tls from "node:tls"; // Hoisted mock for node:tls to avoid ESM spy limitations diff --git a/server/services/hosting.test.ts b/server/services/hosting.test.ts index 62bffcd..430a83c 100644 --- a/server/services/hosting.test.ts +++ b/server/services/hosting.test.ts @@ -1,5 +1,4 @@ /* @vitest-environment node */ - import type { Mock } from "vitest"; import { afterEach, describe, expect, it, vi } from "vitest"; import { detectHosting } from "./hosting"; diff --git a/vitest.config.ts b/vitest.config.ts index bc20b1c..233d5ae 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -5,7 +5,6 @@ import { coverageConfigDefaults, defineConfig } from "vitest/config"; export default defineConfig({ plugins: [tsconfigPaths(), react()], test: { - environment: "jsdom", setupFiles: ["./vitest.setup.ts"], css: true, globals: true,