Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,156 changes: 0 additions & 1,156 deletions packages/lix-sdk/bench.baseline.json

This file was deleted.

1,156 changes: 0 additions & 1,156 deletions packages/lix-sdk/bench.step1.json

This file was deleted.

1,156 changes: 0 additions & 1,156 deletions packages/lix-sdk/bench.step2.json

This file was deleted.

1,138 changes: 0 additions & 1,138 deletions packages/lix-sdk/bench.step5.json

This file was deleted.

6 changes: 3 additions & 3 deletions packages/lix-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@
"devDependencies": {
"@eslint/js": "^9.12.0",
"@opral/tsconfig": "workspace:*",
"@vitest/coverage-v8": "3.2.4",
"@vitest/coverage-v8": "4.0.0-beta.10",
"eslint": "^9.12.0",
"json-schema-to-ts": "^3.1.1",
"prettier": "^3.3.3",
"typescript": "^5.5.4",
"typescript-eslint": "^8.9.0",
"vitest": "3.2.4"
"vitest": "4.0.0-beta.10"
}
}
}
2 changes: 1 addition & 1 deletion packages/lix-sdk/src/database/nano-id.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ test("the alphabet does not contain dashes `-` because they break selecting the
*/
test("polyfill works when crypto is not available", () => {
// Store original crypto
const originalCrypto = global.crypto;
const originalCrypto = globalThis.crypto as any;

// Mock crypto as undefined to test the polyfill
vi.stubGlobal("crypto", undefined);
Expand Down
2 changes: 1 addition & 1 deletion packages/lix-sdk/src/deterministic/nano-id.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ test("polyfill works when crypto is not available", async () => {
const lix = await openLix({});

// Store original crypto
const originalCrypto = global.crypto;
const originalCrypto = globalThis.crypto as any;

// Mock crypto as undefined to test the polyfill
vi.stubGlobal("crypto", undefined);
Expand Down
6 changes: 3 additions & 3 deletions packages/lix-sdk/src/entity/eb-entity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,17 @@ test("ebEntity.hasLabel filters entities by label id", async () => {
{
id: "file0",
path: "/docs/readme.md",
data: new Uint8Array(Buffer.from("# README")),
data: new TextEncoder().encode("# README"),
},
{
id: "file1",
path: "/src/index.ts",
data: new Uint8Array(Buffer.from("console.log('hello')")),
data: new TextEncoder().encode("console.log('hello')"),
},
{
id: "file2",
path: "/package.json",
data: new Uint8Array(Buffer.from("{}")),
data: new TextEncoder().encode("{}"),
},
])
.execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ test.skip("it should detect conflicts", async () => {

const lsaHandler = await createServerProtocolHandler({ environment });

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

// server has/creates value0 for mock_key
await lixOnServer.db
Expand Down
8 changes: 4 additions & 4 deletions packages/lix-sdk/src/services/telemetry/capture.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expect, test, vi } from "vitest";
import { capture } from "./capture.js";

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

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

expect(global.fetch).not.toHaveBeenCalled();
expect((globalThis as any).fetch).not.toHaveBeenCalled();
});

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

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

expect(global.fetch).toHaveBeenCalled();
expect((globalThis as any).fetch).toHaveBeenCalled();
});
12 changes: 6 additions & 6 deletions packages/lix-sdk/src/sync/pull-from-server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test.skip("pull rows of multiple tables from server successfully and applies the
const environment = createLspInMemoryEnvironment();
const lspHandler = await createServerProtocolHandler({ environment });

global.fetch = vi.fn((request) => lspHandler(request));
vi.stubGlobal("fetch", vi.fn((request) => lspHandler(request)) as any);

await lixOnServer.db
.insertInto("account")
Expand Down Expand Up @@ -91,7 +91,7 @@ test.skip("it handles snapshot.content being json binary", async () => {
const environment = createLspInMemoryEnvironment();
const lspHandler = await createServerProtocolHandler({ environment });

global.fetch = vi.fn((request) => lspHandler(request));
vi.stubGlobal("fetch", vi.fn((request) => lspHandler(request)) as any);

const mockSnapshot = mockJsonSnapshot({
location: "Berlin",
Expand Down Expand Up @@ -156,7 +156,7 @@ test.skip("rows changed on the client more recently should not be updated", asyn
const environment = createLspInMemoryEnvironment();
const lspHandler = await createServerProtocolHandler({ environment });

global.fetch = vi.fn((request) => lspHandler(request));
vi.stubGlobal("fetch", vi.fn((request) => lspHandler(request)) as any);

// initialize the lix on the server with the mock data
await lspHandler(
Expand Down Expand Up @@ -201,7 +201,7 @@ test.skip("rows changed on the server more recently should be updated on the cli
const environment = createLspInMemoryEnvironment();
const lspHandler = await createServerProtocolHandler({ environment });

global.fetch = vi.fn((request) => lspHandler(request));
vi.stubGlobal("fetch", vi.fn((request) => lspHandler(request)) as any);

// create a lix and clone it for the client - so they share the same lix id
const remoteLix = await openLix({});
Expand Down Expand Up @@ -308,7 +308,7 @@ test.skip("rows changed on the server more recently should be updated on the cli
// const environment = createLspInMemoryEnvironment();
// const lspHandler = await createServerProtocolHandler({ environment });

// global.fetch = vi.fn((request) => lspHandler(request));
// vi.stubGlobal("fetch", vi.fn((request) => lspHandler(request)) as any);

// // initialize the lix on the server
// await lspHandler(
Expand Down Expand Up @@ -362,7 +362,7 @@ test.skip("non-conflicting changes from the server should for the same version s
const environment = createLspInMemoryEnvironment();
const lspHandler = await createServerProtocolHandler({ environment });

global.fetch = vi.fn((request) => lspHandler(request));
vi.stubGlobal("fetch", vi.fn((request) => lspHandler(request)) as any);

const lixOnServer = await openLix({ blob: await lix.toBlob() });

Expand Down
8 changes: 4 additions & 4 deletions packages/lix-sdk/src/sync/push-to-server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ test.skip("push rows of multiple tables to server successfully", async () => {
const environment = createLspInMemoryEnvironment();
const lspHandler = await createServerProtocolHandler({ environment });

global.fetch = vi.fn((request) => lspHandler(request));
vi.stubGlobal("fetch", vi.fn((request) => lspHandler(request)) as any);

// initialize the lix on the server
await lspHandler(
Expand Down Expand Up @@ -103,7 +103,7 @@ test.skip("push-pull-push with two clients", async () => {
const environment = createLspInMemoryEnvironment();
const lspHandler = await createServerProtocolHandler({ environment });

global.fetch = vi.fn((request) => lspHandler(request));
vi.stubGlobal("fetch", vi.fn((request) => lspHandler(request)) as any);

// Initialize the lix on the server
await lspHandler(
Expand Down Expand Up @@ -282,7 +282,7 @@ test.skip("push-pull-push with two clients", async () => {
// const environment = createLspInMemoryEnvironment();
// const lspHandler = await createServerProtocolHandler({ environment });

// global.fetch = vi.fn((request) => lspHandler(request));
// vi.stubGlobal("fetch", vi.fn((request) => lspHandler(request)) as any);

// // initialize the lix on the server
// await lspHandler(
Expand Down Expand Up @@ -339,7 +339,7 @@ test.todo("it should handle binary values", async () => {
const environment = createLspInMemoryEnvironment();
const lspHandler = await createServerProtocolHandler({ environment });

global.fetch = vi.fn((request) => lspHandler(request));
vi.stubGlobal("fetch", vi.fn((request) => lspHandler(request)) as any);

// initialize the lix on the server
await lspHandler(
Expand Down
8 changes: 4 additions & 4 deletions packages/lix-sdk/src/sync/sync-process.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test.skip("versions should be synced", async () => {
const environment = createLspInMemoryEnvironment();
const lspHandler = await createServerProtocolHandler({ environment });

global.fetch = vi.fn((request) => lspHandler(request));
vi.stubGlobal("fetch", vi.fn((request) => lspHandler(request)) as any);

const lix0 = await openLix({
keyValues: [{ key: "lix_server_url", value: "http://mock.com" }],
Expand Down Expand Up @@ -132,9 +132,9 @@ test.skip("switching synced versions should work", async () => {
const environment = createLspInMemoryEnvironment();
const lspHandler = await createServerProtocolHandler({ environment });

global.fetch = vi.fn((request) => lspHandler(request));
vi.stubGlobal("fetch", vi.fn((request) => lspHandler(request)) as any);
// @ts-expect-error - eases debugging
global.executeSync = executeSync;
(globalThis as any).executeSync = executeSync;

const lix0 = await openLix({
keyValues: [{ key: "lix_sync", value: "true" }],
Expand Down Expand Up @@ -248,7 +248,7 @@ test.skip("switching synced versions should work", async () => {
test.skip("doesnt sync if lix_sync is not true", async () => {
const environment = createLspInMemoryEnvironment();
const lspHandler = await createServerProtocolHandler({ environment });
global.fetch = vi.fn((request) => lspHandler(request));
vi.stubGlobal("fetch", vi.fn((request) => lspHandler(request)) as any);

const lix = await openLix({});

Expand Down
1 change: 1 addition & 0 deletions packages/lix-sdk/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"emitDeclarationOnly": false,
"module": "Node16",
"lib": ["ESNext", "DOM"],
"types": ["vitest/globals"],
"outDir": "./dist",
"rootDir": "./src"
}
Expand Down
22 changes: 16 additions & 6 deletions packages/lix-sdk/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@ import { defineConfig } from "vitest/config";
import codspeedPlugin from "@codspeed/vitest-plugin";

export default defineConfig({
plugins: [process.env.CODSPEED_BENCH ? codspeedPlugin() : undefined],
test: {
// increased default timeout to avoid ci/cd issues
// the high timeout will be needed less with further performance improvements
testTimeout: 120000,
},
plugins: [process.env.CODSPEED_BENCH ? codspeedPlugin() : undefined],
test: {
// increased default timeout to avoid ci/cd issues
// the high timeout will be needed less with further performance improvements
testTimeout: 120000,
// Only pick up tests from src; ignore compiled output in dist
include: ["src/**/*.{test,spec}.{js,ts,jsx,tsx}"],
exclude: [
"node_modules/**",
"dist/**",
"build/**",
"coverage/**",
"**/*.d.ts",
".{git,cache,output,idea}/**",
],
},
});
Loading
Loading