Skip to content

Commit 440ac12

Browse files
committed
fix tests
1 parent 70e8e18 commit 440ac12

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

frontend/src/core/ai/context/providers/__tests__/cell-output.test.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* Copyright 2024 Marimo. All rights reserved. */
22

3-
import { beforeEach, describe, expect, it, vi } from "vitest";
3+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
44
import { Mocks } from "@/__mocks__/common";
55

66
// Mock the external dependencies
@@ -320,8 +320,12 @@ describe("Cell output utility functions", () => {
320320
describe("HTML content parsing", () => {
321321
let provider: CellOutputContextProvider;
322322
let mockStore: JotaiStore;
323+
let originalCreateElement: typeof document.createElement;
323324

324325
beforeEach(() => {
326+
// Save original createElement
327+
originalCreateElement = document.createElement;
328+
325329
// Mock DOM methods for HTML parsing
326330
const mockDiv = {
327331
innerHTML: "",
@@ -343,6 +347,13 @@ describe("Cell output utility functions", () => {
343347
provider = new CellOutputContextProvider(mockStore);
344348
});
345349

350+
afterEach(() => {
351+
// Restore original createElement to prevent mock pollution
352+
if (originalCreateElement) {
353+
document.createElement = originalCreateElement;
354+
}
355+
});
356+
346357
it("should extract text content from HTML", () => {
347358
const htmlContent = "<p>Hello <strong>world</strong>!</p>";
348359

0 commit comments

Comments
 (0)