Skip to content

Commit 6ca1ff5

Browse files
Merge pull request #3689 from opral/upgrade-vitest
upgrade vitest to v4
2 parents 2ecf4f5 + ec6da30 commit 6ca1ff5

File tree

16 files changed

+254
-4662
lines changed

16 files changed

+254
-4662
lines changed

packages/lix-sdk/bench.baseline.json

Lines changed: 0 additions & 1156 deletions
This file was deleted.

packages/lix-sdk/bench.step1.json

Lines changed: 0 additions & 1156 deletions
This file was deleted.

packages/lix-sdk/bench.step2.json

Lines changed: 0 additions & 1156 deletions
This file was deleted.

packages/lix-sdk/bench.step5.json

Lines changed: 0 additions & 1138 deletions
This file was deleted.

packages/lix-sdk/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@
6464
"devDependencies": {
6565
"@eslint/js": "^9.12.0",
6666
"@opral/tsconfig": "workspace:*",
67-
"@vitest/coverage-v8": "3.2.4",
67+
"@vitest/coverage-v8": "4.0.0-beta.10",
6868
"eslint": "^9.12.0",
6969
"json-schema-to-ts": "^3.1.1",
7070
"prettier": "^3.3.3",
7171
"typescript": "^5.5.4",
7272
"typescript-eslint": "^8.9.0",
73-
"vitest": "3.2.4"
73+
"vitest": "4.0.0-beta.10"
7474
}
75-
}
75+
}

packages/lix-sdk/src/database/nano-id.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ test("the alphabet does not contain dashes `-` because they break selecting the
2222
*/
2323
test("polyfill works when crypto is not available", () => {
2424
// Store original crypto
25-
const originalCrypto = global.crypto;
25+
const originalCrypto = globalThis.crypto as any;
2626

2727
// Mock crypto as undefined to test the polyfill
2828
vi.stubGlobal("crypto", undefined);

packages/lix-sdk/src/deterministic/nano-id.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ test("polyfill works when crypto is not available", async () => {
180180
const lix = await openLix({});
181181

182182
// Store original crypto
183-
const originalCrypto = global.crypto;
183+
const originalCrypto = globalThis.crypto as any;
184184

185185
// Mock crypto as undefined to test the polyfill
186186
vi.stubGlobal("crypto", undefined);

packages/lix-sdk/src/entity/eb-entity.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,17 @@ test("ebEntity.hasLabel filters entities by label id", async () => {
7676
{
7777
id: "file0",
7878
path: "/docs/readme.md",
79-
data: new Uint8Array(Buffer.from("# README")),
79+
data: new TextEncoder().encode("# README"),
8080
},
8181
{
8282
id: "file1",
8383
path: "/src/index.ts",
84-
data: new Uint8Array(Buffer.from("console.log('hello')")),
84+
data: new TextEncoder().encode("console.log('hello')"),
8585
},
8686
{
8787
id: "file2",
8888
path: "/package.json",
89-
data: new Uint8Array(Buffer.from("{}")),
89+
data: new TextEncoder().encode("{}"),
9090
},
9191
])
9292
.execute();

packages/lix-sdk/src/server-protocol-handler/routes/push-v1.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ test.skip("it should detect conflicts", async () => {
182182

183183
const lsaHandler = await createServerProtocolHandler({ environment });
184184

185-
global.fetch = vi.fn((request) => lsaHandler(request));
185+
vi.stubGlobal("fetch", vi.fn((request) => lsaHandler(request)) as any);
186186

187187
// server has/creates value0 for mock_key
188188
await lixOnServer.db

packages/lix-sdk/src/services/telemetry/capture.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect, test, vi } from "vitest";
22
import { capture } from "./capture.js";
33

44
test("it should not capture if telemetry is off", async () => {
5-
global.fetch = vi.fn(() => Promise.resolve(new Response()));
5+
vi.stubGlobal("fetch", vi.fn(() => Promise.resolve(new Response())) as any);
66

77
vi.mock("../env-variables/index.js", async () => {
88
return {
@@ -19,11 +19,11 @@ test("it should not capture if telemetry is off", async () => {
1919
properties: {},
2020
});
2121

22-
expect(global.fetch).not.toHaveBeenCalled();
22+
expect((globalThis as any).fetch).not.toHaveBeenCalled();
2323
});
2424

2525
test("it should not capture if telemetry is NOT off", async () => {
26-
global.fetch = vi.fn(() => Promise.resolve(new Response()));
26+
vi.stubGlobal("fetch", vi.fn(() => Promise.resolve(new Response())) as any);
2727

2828
vi.mock("../env-variables/index.js", async () => {
2929
return {
@@ -40,5 +40,5 @@ test("it should not capture if telemetry is NOT off", async () => {
4040
properties: {},
4141
});
4242

43-
expect(global.fetch).toHaveBeenCalled();
43+
expect((globalThis as any).fetch).toHaveBeenCalled();
4444
});

0 commit comments

Comments
 (0)