Skip to content

Commit 4237912

Browse files
te6-inclaude
andauthored
refactor: migrate from vitest to bun test runner (#1199)
* refactor: migrate from vitest to bun test runner # Conflicts: # packages/codemod/src/transforms/replace-custom-seed-design-vars/__testfixtures__/basic.output.ts * fix: `--dots` * test: fix test * test: restore mocked window globals after tests Add afterAll cleanup to restore original window.ResizeObserver and PointerCapture methods after test suites complete. This ensures proper test isolation and prevents mock leakage between test files. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent c2ab2a3 commit 4237912

File tree

81 files changed

+586
-785
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+586
-785
lines changed

.claude/hooks/post-edit-tasks.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,20 @@ elif [[ "$FILE_PATH" == *"packages/qvism-preset/"* ]]; then
3232

3333
elif [[ "$FILE_PATH" == *"packages/react-headless/"* ]]; then
3434
run_with_feedback bun headless:build
35-
run_with_feedback bun headless:test --reporter=dot
35+
run_with_feedback bun headless:test --dots
3636
run_with_feedback bun --filter @seed-design/react build
37-
run_with_feedback bun react:test --reporter=dot
37+
run_with_feedback bun react:test --dots
3838

3939
elif [[ "$FILE_PATH" == *"packages/react/"* ]]; then
4040
run_with_feedback bun --filter @seed-design/react build
41-
run_with_feedback bun react:test --reporter=dot
41+
run_with_feedback bun react:test --dots
4242

4343
elif [[ "$FILE_PATH" == *"packages/figma/"* ]]; then
4444
run_with_feedback bun --filter @seed-design/figma build
4545

4646
elif [[ "$FILE_PATH" == *"packages/cli/"* ]]; then
4747
run_with_feedback bun --filter @seed-design/cli build
48-
run_with_feedback bun --filter @seed-design/cli test --reporter=dot
48+
run_with_feedback bun --filter @seed-design/cli test --dots
4949

5050
elif [[ "$FILE_PATH" == *"packages/stackflow/"* ]]; then
5151
run_with_feedback bun --filter @seed-design/stackflow build
@@ -57,9 +57,9 @@ fi
5757
if [[ "$FILE_PATH" == *"ecosystem/rootage/"* ]]; then
5858
run_with_feedback bun --filter @seed-design/rootage-core build
5959
run_with_feedback bun --filter @seed-design/rootage-cli build
60-
run_with_feedback bun rootage:test --reporter=dot
60+
run_with_feedback bun rootage:test --dots
6161
elif [[ "$FILE_PATH" == *"ecosystem/qvism/"* ]]; then
6262
run_with_feedback bun --filter @seed-design/qvism-core build
6363
run_with_feedback bun --filter @seed-design/qvism-cli build
64-
run_with_feedback bun --filter @seed-design/qvism-core test --reporter=dot
64+
run_with_feedback bun --filter @seed-design/qvism-core test --dots
6565
fi

.vscode/extensions.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"formulahendry.auto-close-tag",
55
"redhat.vscode-yaml",
66
"esbenp.prettier-vscode",
7-
"oven.bun-vscode",
8-
"vitest.explorer"
7+
"oven.bun-vscode"
98
]
109
}

bun.lock

Lines changed: 51 additions & 198 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bunfig.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[install]
22
linker = "isolated"
33
minimumReleaseAge = 86400 # 1 day
4+
5+
[test]
6+
preload = ["./scripts/happydom.ts", "./scripts/testing-library.ts"]

ecosystem/figma-extractor/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
},
99
"scripts": {
1010
"build": "bun build.mjs && tsc",
11-
"lint:publish": "bun publint",
12-
"test": "vitest"
11+
"lint:publish": "bun publint"
1312
},
1413
"bin": {
1514
"figma-extractor": "./bin/index.mjs"

ecosystem/figma-extractor/src/api/__mocks__/client.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import { vi } from "vitest";
1+
import { mock } from "bun:test";
22
import path from "path";
33
import fs from "fs-extra";
44
import { fileURLToPath } from "url";
55

66
const __dirname = path.dirname(fileURLToPath(import.meta.url));
77
const fixturesDir = path.join(__dirname, "../../test/fixtures");
88

9-
export const createApiClient = vi.fn(() => {
9+
export const createApiClient = mock(() => {
1010
return {
11-
getFileComponents: vi.fn(async () => {
11+
getFileComponents: mock(async () => {
1212
return await fs.readJson(path.join(fixturesDir, "file-components.json"));
1313
}),
14-
getFileComponentSets: vi.fn(async () => {
14+
getFileComponentSets: mock(async () => {
1515
return await fs.readJson(path.join(fixturesDir, "file-component-sets.json"));
1616
}),
17-
getFileNodes: vi.fn(async (_, { ids }: { ids: string }) => {
17+
getFileNodes: mock(async (_, { ids }: { ids: string }) => {
1818
const componentNodesData = await fs.readJson(path.join(fixturesDir, "component-nodes.json"));
1919
const componentSetNodesData = await fs.readJson(
2020
path.join(fixturesDir, "component-set-nodes.json"),
@@ -36,10 +36,10 @@ export const createApiClient = vi.fn(() => {
3636

3737
return { nodes: filteredNodes };
3838
}),
39-
getFileStyles: vi.fn(async () => {
39+
getFileStyles: mock(async () => {
4040
return await fs.readJson(path.join(fixturesDir, "file-styles.json"));
4141
}),
42-
getLocalVariables: vi.fn(async () => {
42+
getLocalVariables: mock(async () => {
4343
return await fs.readJson(path.join(fixturesDir, "file-variables.json"));
4444
}),
4545
};

ecosystem/figma-extractor/src/test/builder.test.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { describe, it, expect, vi, beforeEach } from "vitest";
2-
import { createPipeline } from "../pipeline/builder";
3-
import { createApiClient } from "../api/client";
1+
import { describe, it, expect, mock, beforeEach } from "bun:test";
42

5-
vi.mock("../api/client");
3+
mock.module("../api/client", () => import("../api/__mocks__/client"));
4+
5+
const { createPipeline } = await import("../pipeline/builder");
6+
const { createApiClient } = await import("../api/client");
67

78
const testItems = [
89
{ name: "Button", type: "COMPONENT", order: 2, priority: 3 },
@@ -29,10 +30,10 @@ describe("pipeline builder", () => {
2930
},
3031
};
3132

32-
const mockSource = vi.fn();
33+
const mockSource = mock(() => {});
3334

3435
beforeEach(() => {
35-
vi.clearAllMocks();
36+
mockSource.mockClear();
3637
mockSource.mockResolvedValue(testItems);
3738
});
3839

ecosystem/figma-extractor/src/test/nodes.test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
import { describe, it, expect, vi } from "vitest";
2-
import { getComponentMetadataItemsInFile, getComponentSetMetadataItemsInFile } from "../api/nodes";
3-
import { createApiClient } from "../api/client";
1+
import { describe, it, expect, mock } from "bun:test";
42

5-
vi.mock("../api/client");
3+
mock.module("../api/client", () => import("../api/__mocks__/client"));
4+
5+
const { getComponentMetadataItemsInFile, getComponentSetMetadataItemsInFile } = await import(
6+
"../api/nodes"
7+
);
8+
const { createApiClient } = await import("../api/client");
69

710
describe("nodes", () => {
811
const fileKey = "test-file-key";

ecosystem/figma-extractor/src/test/sources.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { describe, it, expect, vi } from "vitest";
2-
import { sources } from "../pipeline/sources";
3-
import { createApiClient } from "../api/client";
1+
import { describe, it, expect, mock } from "bun:test";
42

5-
vi.mock("../api/client");
3+
mock.module("../api/client", () => import("../api/__mocks__/client"));
4+
5+
const { sources } = await import("../pipeline/sources");
6+
const { createApiClient } = await import("../api/client");
67

78
describe("sources", () => {
89
const fileKey = "test-file-key";

ecosystem/figma-extractor/src/test/styles.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { describe, it, expect, vi } from "vitest";
2-
import { getStylesMetadataInFile } from "../api/styles";
3-
import { createApiClient } from "../api/client";
1+
import { describe, it, expect, mock } from "bun:test";
42

5-
vi.mock("../api/client");
3+
mock.module("../api/client", () => import("../api/__mocks__/client"));
4+
5+
const { getStylesMetadataInFile } = await import("../api/styles");
6+
const { createApiClient } = await import("../api/client");
67

78
describe("styles", () => {
89
const fileKey = "test-file-key";

0 commit comments

Comments
 (0)