Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
test(standalone): increase timeout due to coverage
Elian Dorand6685c32b662
diff --git a/packages/trilium-core/src/services/encryption/crypto.spec.ts b/packages/trilium-core/src/services/encryption/crypto.spec.tsindex 37b7ae6058..cdf7edd914 100644--- a/packages/trilium-core/src/services/encryption/crypto.spec.ts+++ b/packages/trilium-core/src/services/encryption/crypto.spec.ts@@ -1,4 +1,4 @@-import { afterEach, beforeAll, describe, expect, it } from "vitest";+import { afterEach, beforeAll, describe, expect, it, vi } from "vitest";import { decodeUtf8, encodeUtf8 } from "../utils/binary.js";import { type CryptoProvider, getCrypto, initCrypto } from "./crypto.js";@@ -13,6 +13,15 @@ import { type CryptoProvider, getCrypto, initCrypto } from "./crypto.js";// initCrypto() restore the original in afterEach so the rest of the file keeps// seeing the real provider.+// scrypt (N=16384) runs in pure JS (scrypt-js) under the browser provider, which is+// ~10x slower under V8 coverage instrumentation than Node's native scryptSync. Give the+// standalone (happy-dom) suite a larger timeout; the server suite keeps the strict+// default. The derived bytes are identical across runtimes — only the speed differs.+const isBrowserRuntime = typeof window !== "undefined";+if (isBrowserRuntime) {+ vi.setConfig({ testTimeout: 60000, hookTimeout: 60000 });+}+describe("crypto registry", () => {let original: CryptoProvider;diff --git a/packages/trilium-core/src/services/encryption/password.spec.ts b/packages/trilium-core/src/services/encryption/password.spec.tsindex 5c384c1ec9..60ec41c3ec 100644--- a/packages/trilium-core/src/services/encryption/password.spec.ts+++ b/packages/trilium-core/src/services/encryption/password.spec.ts@@ -1,4 +1,4 @@-import { describe, expect, it } from "vitest";+import { describe, expect, it, vi } from "vitest";import options from "../options.js";import { getContext } from "../context.js";@@ -13,6 +13,15 @@ import passwordService from "./password.js";// the destructive reset/re-set at the end.const FIXTURE_PASSWORD = "demo1234";+// scrypt (N=16384) runs in pure JS (scrypt-js) under the browser provider, which is+// ~10x slower under V8 coverage instrumentation than Node's native scryptSync. Give the+// standalone (happy-dom) suite a larger timeout; the server suite keeps the strict+// default. The derived bytes are identical across runtimes — only the speed differs.+const isBrowserRuntime = typeof window !== "undefined";+if (isBrowserRuntime) {+ vi.setConfig({ testTimeout: 60000, hookTimeout: 60000 });+}+/*** Wraps a callback in a CLS context. The mutating password operations call* options.setOption/createOption, which save BOption entities and thereforediff --git a/packages/trilium-core/src/services/encryption/password_encryption.spec.ts b/packages/trilium-core/src/services/encryption/password_encryption.spec.tsindex 71df28856c..427363bedf 100644--- a/packages/trilium-core/src/services/encryption/password_encryption.spec.ts+++ b/packages/trilium-core/src/services/encryption/password_encryption.spec.ts@@ -1,4 +1,4 @@-import { describe, expect, it } from "vitest";+import { describe, expect, it, vi } from "vitest";import options from "../options.js";import { getContext } from "../context.js";@@ -13,6 +13,15 @@ import passwordEncryption from "./password_encryption.js";// so the destructive verification-hash test is kept last.const FIXTURE_PASSWORD = "demo1234";+// scrypt (N=16384) runs in pure JS (scrypt-js) under the browser provider, which is+// ~10x slower under V8 coverage instrumentation than Node's native scryptSync. Give the+// standalone (happy-dom) suite a larger timeout; the server suite keeps the strict+// default. The derived bytes are identical across runtimes — only the speed differs.+const isBrowserRuntime = typeof window !== "undefined";+if (isBrowserRuntime) {+ vi.setConfig({ testTimeout: 60000, hookTimeout: 60000 });+}+/*** Wraps a callback in a CLS context. setDataKey calls options.setOption, which* saves a BOption entity and therefore requires an initialised CLS context.diff --git a/packages/trilium-core/src/services/encryption/scrypt.spec.ts b/packages/trilium-core/src/services/encryption/scrypt.spec.tsindex ad2d908130..b7434cec0a 100644--- a/packages/trilium-core/src/services/encryption/scrypt.spec.ts+++ b/packages/trilium-core/src/services/encryption/scrypt.spec.ts@@ -1,4 +1,4 @@-import { describe, expect, it } from "vitest";+import { describe, expect, it, vi } from "vitest";import options from "../options.js";import { encodeBase64 } from "../utils/binary.js";@@ -16,6 +16,15 @@ import scryptService, {// is required. Each spec file runs in its own vitest fork (pool: "forks").const FIXTURE_PASSWORD = "demo1234";+// scrypt (N=16384) runs in pure JS (scrypt-js) under the browser provider, which is+// ~10x slower under V8 coverage instrumentation than Node's native scryptSync. Give the+// standalone (happy-dom) suite a larger timeout; the server suite keeps the strict+// default. The derived bytes are identical across runtimes — only the speed differs.+const isBrowserRuntime = typeof window !== "undefined";+if (isBrowserRuntime) {+ vi.setConfig({ testTimeout: 60000, hookTimeout: 60000 });+}+describe("scrypt (real DB)", () => {describe("getScryptHash", () => {it("derives a deterministic 32-byte key for a given (password, salt)", async () => {