From d3c29e782991894880c6a6a14e6b82e8afc60f06 Mon Sep 17 00:00:00 2001 From: Marius Maaland Date: Wed, 7 Oct 2026 20:22:03 +0200 Subject: [PATCH] Start PGlite once before the Postgres store tests (#59) The first PGlite in a process compiles its WebAssembly, which can take more than the first test's 5 s on a busy machine. A beforeAll with its own time limit now pays that once, before any test. Closes #59 Co-Authored-By: Claude Opus 5.5 --- packages/store-postgres/src/store.test.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/store-postgres/src/store.test.ts b/packages/store-postgres/src/store.test.ts index e048715..7c2425b 100644 --- a/packages/store-postgres/src/store.test.ts +++ b/packages/store-postgres/src/store.test.ts @@ -1,6 +1,6 @@ import { readFileSync } from 'node:fs'; import { PGlite } from '@electric-sql/pglite'; -import { describe, expect, test } from 'vitest'; +import { beforeAll, describe, expect, test } from 'vitest'; import { describeStore } from '../../core/test/store-contract.ts'; import { migrate } from './migrate.ts'; import type { Sql } from './sql.ts'; @@ -27,6 +27,12 @@ async function freshDatabase(): Promise { return sql; } +// The first PGlite in a process compiles its WebAssembly, which can take seconds on a busy +// machine. Do it here, with its own time limit, so no test pays for it. +beforeAll(async () => { + await (await PGlite.create()).close(); +}, 60_000); + describeStore('PostgresStore', async () => new PostgresStore(await freshDatabase())); describe('migrate', () => {