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
6 changes: 3 additions & 3 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ Subprocess and provisioning-lock unit tests start alongside the platform project
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.
Unit files and most API integration files use isolated worker threads to reduce startup time. On Linux,
API integration files 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 integration files and the PGlite unit files (`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.
This keeps database engines from competing with all framework compilers at startup. Keep module
isolation enabled: these suites mock globals, keep database state, and exercise real process/lock boundaries.
Expand Down
20 changes: 20 additions & 0 deletions packages/void/test/unit/test-projects.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,26 @@ 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
Expand Down
4 changes: 3 additions & 1 deletion test/affected.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ export async function runAffected(root, values) {
watch: false,
changed: initial.full ? false : changed,
experimental: { vcsProvider },
...(values.unit ? { project: ['unit', 'cli-unit', 'platform-unit'] } : {}),
...(values.unit
? { project: ['unit', 'cli-unit', 'platform-unit', 'platform-unit-pglite'] }
: {}),
});
try {
const all = await vitest.globTestSpecifications();
Expand Down
23 changes: 22 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ const apiTimezoneTests = [
'platform/packages/api/test/integration/api-delete-accounting.test.ts',
'platform/packages/api/test/integration/email-connections.test.ts',
];
// Platform unit files that start PGlite. Add new PGlite unit files here.
const pgliteUnitTests = [
'platform/packages/api/test/unit/admin-upgrade-compatibility.test.ts',
'platform/packages/api/test/unit/email-migration.test.ts',
'platform/packages/api/test/unit/email-shared-recipient-migration.test.ts',
'platform/packages/api/test/unit/github-authority-constraints-migration.test.ts',
'platform/packages/api/test/unit/github-authority-migration.test.ts',
];
const cliUnitTests = [
'packages/void/test/unit/cf-*.test.ts',
'packages/void/test/unit/provision-*.test.ts',
Expand Down Expand Up @@ -443,7 +451,20 @@ export default defineConfig({
fsModuleCache: true,
pool: 'threads',
include: ['platform/packages/*/test/**/*.test.ts'],
exclude: ['platform/packages/api/test/integration/**'],
exclude: ['platform/packages/api/test/integration/**', ...pgliteUnitTests],
maxWorkers,
},
},
{
extends: false,
resolve: { alias: platformAlias },
test: {
name: 'platform-unit-pglite',
fsModuleCache: true,
// 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',
include: pgliteUnitTests,
maxWorkers,
},
},
Expand Down
Loading