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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
- run: vp run build:core
if: ${{ matrix.shard == 'unit' }}

- run: vp test run --project unit --project cli-unit
- run: vp test run --project unit --project unit-pglite --project cli-unit
if: ${{ matrix.shard == 'unit' }}

- run: vp run build
Expand Down
6 changes: 3 additions & 3 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ changes to metaframework output still need `build:all` and the artifact check.
For a leaf-module edit with known import-based consumers, Vitest's native related command is useful:

```sh
vp test related --run packages/void/src/runtime/sse.ts --project unit --project cli-unit
vp test related --run packages/void/src/runtime/sse.ts --project unit --project unit-pglite --project cli-unit
vp test list packages/void/test/unit/plugin-routing.test.ts --filesOnly
```

Expand Down Expand Up @@ -89,9 +89,9 @@ or hanging tests when they occur instead of routinely increasing timeouts.

Subprocess and provisioning-lock unit tests start alongside the platform projects so their real
process deadlines can overlap database work. The remaining SDK unit and integration files then
share a scheduling phase. `vp run test:unit` includes both `unit` and `cli-unit`; CI does the same.
share a scheduling phase. `vp run test:unit` includes `unit`, `unit-pglite`, and `cli-unit`; CI does the same.
Unit files and most API integration files use isolated worker threads to reduce startup time. On Linux,
API integration files and the PGlite unit files (`platform-unit-pglite`) use forks to isolate PGlite's
API integration files and the PGlite unit files (`unit-pglite`, `platform-unit-pglite`) use forks to isolate PGlite's
WebAssembly JIT allocations after native Node 24 cleanup crashes in shared worker processes. API tests
that change the process timezone also use forks, because threads cannot change Node's timezone. Select every
API file with `vp test run --project 'platform-api-integration*'`. SDK integration files use forks.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"test:pages:svelte-solid": "vp test run --project parallel-integration packages/svelte packages/solid",
"test:platform": "vp test run --project 'platform-*'",
"test:profile": "vp test run --reporter=default --experimental.importDurations.print --experimental.importDurations.limit=20",
"test:unit": "vp test run --project unit --project cli-unit",
"test:unit": "vp test run --project unit --project unit-pglite --project cli-unit",
"uninstall:void-dev": "node scripts/void-dev-link.mjs uninstall"
},
"devDependencies": {
Expand Down
22 changes: 1 addition & 21 deletions packages/void/test/unit/test-projects.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,30 +46,10 @@ it('keeps process-timezone tests in forks', () => {
}
});

it('assigns every platform unit file exactly once and keeps PGlite files in their own project', () => {
const discovered = [
...globSync('platform/packages/*/test/**/*.test.ts', {
cwd: root,
exclude: ['platform/packages/api/test/integration/**'],
}),
];
const unitProjects = projects.filter((project) => project.test.name.startsWith('platform-unit'));
const selected = unitProjects.flatMap(files);
expect(selected.sort()).toEqual(discovered.sort());
expect(new Set(selected).size).toBe(discovered.length);
for (const project of unitProjects) {
for (const file of files(project)) {
if (readFileSync(join(root, file), 'utf8').includes('@electric-sql/pglite')) {
expect(project.test.name, file).toBe('platform-unit-pglite');
}
}
}
});

it('assigns every SDK unit file exactly once including the subprocess project', () => {
const discovered = [...globSync('packages/*/test/unit/**/*.test.ts', { cwd: root })];
const selected = projects
.filter((project) => ['unit', 'cli-unit'].includes(project.test.name))
.filter((project) => ['unit', 'unit-pglite', 'cli-unit'].includes(project.test.name))
Comment thread
Brooooooklyn marked this conversation as resolved.
.flatMap(files);
expect(selected.sort()).toEqual(discovered.sort());
expect(new Set(selected).size).toBe(discovered.length);
Expand Down
2 changes: 1 addition & 1 deletion test/affected.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export async function runAffected(root, values) {
changed: initial.full ? false : changed,
experimental: { vcsProvider },
...(values.unit
? { project: ['unit', 'cli-unit', 'platform-unit', 'platform-unit-pglite'] }
? { project: ['unit', 'unit-pglite', 'cli-unit', 'platform-unit', 'platform-unit-pglite'] }
: {}),
});
try {
Expand Down
23 changes: 22 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ const cliUnitTests = [
'packages/void/test/unit/provision-*.test.ts',
'packages/void/test/unit/deploy-drift.test.ts',
];
// SDK unit files that start PGlite. Add new PGlite unit files here.
const sdkPgliteUnitTests = [
'packages/void/test/unit/db-export-roundtrip.test.ts',
'packages/void/test/unit/platform-database-lock.test.ts',
'packages/void/test/unit/platform-database-migrations.test.ts',
'packages/void/test/unit/runner-pg.test.ts',
];

// Vitest forwards a FILTERED env to test workers — in CI only VOID_E2E_CF_TOKEN survives, while
// VOID_E2E_CF_ACCOUNT_ID and VOID_E2E_RUN_ID are dropped. The gated live Cloudflare deploy e2e
Expand Down Expand Up @@ -434,7 +441,7 @@ export default defineConfig({
name: 'unit',
fsModuleCache: true,
include: ['packages/*/test/unit/**/*.test.ts'],
exclude: cliUnitTests,
exclude: [...cliUnitTests, ...sdkPgliteUnitTests],
sequence: { groupOrder: 2 },
pool: 'threads',
maxWorkers,
Expand All @@ -443,6 +450,20 @@ export default defineConfig({
...(process.platform === 'win32' ? { testTimeout: 20_000 } : {}),
},
},
{
extends: false,
test: {
name: 'unit-pglite',
fsModuleCache: true,
include: sdkPgliteUnitTests,
sequence: { groupOrder: 2 },
// Node 24 on Linux can abort the whole run while unregistering PGlite's Wasm JIT
// allocations across worker threads. Keep each database in its own process.
pool: process.platform === 'linux' ? 'forks' : 'threads',
maxWorkers,
...(process.platform === 'win32' ? { testTimeout: 20_000 } : {}),
},
},
{
extends: false,
resolve: { alias: platformAlias },
Expand Down
Loading