chore: migrate from jsdom to happy-dom for testing environment

This commit is contained in:
Amruth Pillai
2026-05-10 20:46:28 +02:00
parent b321e01658
commit 7a60a42a04
15 changed files with 114 additions and 316 deletions
+1 -1
View File
@@ -4,5 +4,5 @@ import { createVitestProjectConfig } from "../../vitest.shared";
export default createVitestProjectConfig({
name: "@reactive-resume/email",
dirname: fileURLToPath(new URL(".", import.meta.url)),
environment: "jsdom",
environment: "happy-dom",
});
+1 -1
View File
@@ -4,5 +4,5 @@ import { createVitestProjectConfig } from "../../vitest.shared";
export default createVitestProjectConfig({
name: "@reactive-resume/import",
dirname: fileURLToPath(new URL(".", import.meta.url)),
environment: "jsdom",
environment: "happy-dom",
});
+2 -2
View File
@@ -107,7 +107,7 @@ describe("getResumeSectionTitle", () => {
customSections: [
{
id: "ext-1",
type: "cover-letter",
type: "cover-letter" as const,
title: "My Cover Letter",
columns: 1,
hidden: false,
@@ -124,7 +124,7 @@ describe("getResumeSectionTitle", () => {
customSections: [
{
id: "ext-1",
type: "cover-letter",
type: "cover-letter" as const,
title: "",
columns: 1,
hidden: false,
+6 -2
View File
@@ -138,8 +138,12 @@ describe("ComboboxCollection", () => {
<ComboboxInput />
<ComboboxContent>
<ComboboxList>
<ComboboxCollection items={items}>
{(item) => <ComboboxItem value={item}>{item}</ComboboxItem>}
<ComboboxCollection>
{(item) => (
<ComboboxItem key={item} value={item}>
{item}
</ComboboxItem>
)}
</ComboboxCollection>
</ComboboxList>
</ComboboxContent>
+2 -2
View File
@@ -40,12 +40,12 @@ function FormLabel({ className, ...props }: React.ComponentProps<typeof Label>)
);
}
function FormControl(props: useRender.ComponentProps<"div">) {
function FormControl({ render, ...props }: useRender.ComponentProps<"div">) {
const { id, hasError } = useFormItem();
return useRender({
...props,
defaultTagName: "div",
render,
state: { slot: "form-control" },
props: {
id: `${id}-form-item`,
@@ -5,7 +5,7 @@ import { ResizableGroup, ResizablePanel, ResizableSeparator } from "./resizable"
describe("ResizableGroup", () => {
it("renders with data-slot='resizable-panel-group'", () => {
const { container } = render(
<ResizableGroup direction="horizontal">
<ResizableGroup orientation="horizontal">
<ResizablePanel>A</ResizablePanel>
<ResizableSeparator />
<ResizablePanel>B</ResizablePanel>
@@ -16,7 +16,7 @@ describe("ResizableGroup", () => {
it("merges custom className", () => {
const { container } = render(
<ResizableGroup direction="horizontal" className="my-group">
<ResizableGroup orientation="horizontal" className="my-group">
<ResizablePanel>x</ResizablePanel>
</ResizableGroup>,
);
@@ -27,7 +27,7 @@ describe("ResizableGroup", () => {
describe("ResizablePanel", () => {
it("renders with data-slot='resizable-panel'", () => {
const { container } = render(
<ResizableGroup direction="horizontal">
<ResizableGroup orientation="horizontal">
<ResizablePanel>x</ResizablePanel>
</ResizableGroup>,
);
@@ -38,7 +38,7 @@ describe("ResizablePanel", () => {
describe("ResizableSeparator", () => {
it("renders with data-slot='resizable-handle' and no inner handle by default", () => {
const { container } = render(
<ResizableGroup direction="horizontal">
<ResizableGroup orientation="horizontal">
<ResizablePanel>A</ResizablePanel>
<ResizableSeparator />
<ResizablePanel>B</ResizablePanel>
@@ -52,7 +52,7 @@ describe("ResizableSeparator", () => {
it("renders inner handle when withHandle=true", () => {
const { container } = render(
<ResizableGroup direction="horizontal">
<ResizableGroup orientation="horizontal">
<ResizablePanel>A</ResizablePanel>
<ResizableSeparator withHandle />
<ResizablePanel>B</ResizablePanel>
+1
View File
@@ -0,0 +1 @@
import "@testing-library/jest-dom/vitest";
+1 -1
View File
@@ -4,5 +4,5 @@ import { createVitestProjectConfig } from "../../vitest.shared";
export default createVitestProjectConfig({
name: "@reactive-resume/ui",
dirname: fileURLToPath(new URL(".", import.meta.url)),
environment: "jsdom",
environment: "happy-dom",
});
+1 -1
View File
@@ -43,7 +43,7 @@ describe("filterFieldValues", () => {
it("filters out fields with missing keys", () => {
const fields = [{ key: "name" as const }];
const result = filterFieldValues({}, ...fields);
const result = filterFieldValues<"name", { key: "name" }>({}, ...fields);
expect(result.size).toBe(0);
});
+9 -9
View File
@@ -1,5 +1,5 @@
/**
* @vitest-environment jsdom
* @vitest-environment happy-dom
*/
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { downloadFromUrl, downloadWithAnchor, generateFilename } from "./file";
@@ -31,8 +31,8 @@ describe("generateFilename", () => {
});
describe("downloadWithAnchor", () => {
let createObjectURLSpy: ReturnType<typeof vi.fn>;
let revokeObjectURLSpy: ReturnType<typeof vi.fn>;
let createObjectURLSpy: ReturnType<typeof vi.fn<typeof URL.createObjectURL>>;
let revokeObjectURLSpy: ReturnType<typeof vi.fn<typeof URL.revokeObjectURL>>;
let originalCreate: typeof URL.createObjectURL;
let originalRevoke: typeof URL.revokeObjectURL;
@@ -40,8 +40,8 @@ describe("downloadWithAnchor", () => {
vi.useFakeTimers();
originalCreate = URL.createObjectURL;
originalRevoke = URL.revokeObjectURL;
createObjectURLSpy = vi.fn(() => "blob:mock-url");
revokeObjectURLSpy = vi.fn();
createObjectURLSpy = vi.fn<typeof URL.createObjectURL>(() => "blob:mock-url");
revokeObjectURLSpy = vi.fn<typeof URL.revokeObjectURL>();
URL.createObjectURL = createObjectURLSpy;
URL.revokeObjectURL = revokeObjectURLSpy;
});
@@ -91,8 +91,8 @@ describe("downloadWithAnchor", () => {
describe("downloadFromUrl", () => {
let originalFetch: typeof global.fetch;
let createObjectURLSpy: ReturnType<typeof vi.fn>;
let revokeObjectURLSpy: ReturnType<typeof vi.fn>;
let createObjectURLSpy: ReturnType<typeof vi.fn<typeof URL.createObjectURL>>;
let revokeObjectURLSpy: ReturnType<typeof vi.fn<typeof URL.revokeObjectURL>>;
let originalCreate: typeof URL.createObjectURL;
let originalRevoke: typeof URL.revokeObjectURL;
@@ -100,8 +100,8 @@ describe("downloadFromUrl", () => {
originalFetch = global.fetch;
originalCreate = URL.createObjectURL;
originalRevoke = URL.revokeObjectURL;
createObjectURLSpy = vi.fn(() => "blob:mock-url");
revokeObjectURLSpy = vi.fn();
createObjectURLSpy = vi.fn<typeof URL.createObjectURL>(() => "blob:mock-url");
revokeObjectURLSpy = vi.fn<typeof URL.revokeObjectURL>();
URL.createObjectURL = createObjectURLSpy;
URL.revokeObjectURL = revokeObjectURLSpy;
});
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* @vitest-environment jsdom
* @vitest-environment happy-dom
*/
import { describe, expect, it } from "vitest";
import { isObject, sanitizeCss, sanitizeHtml } from "./sanitize";