testing/cross_backend/make_cross_backend_project.ts

Generic vitest project factory for cross-backend integration suites.

One vitest project per spawned backend; each runs the consumer's shared *.cross.test.ts files against its own bootstrapped binary. The paired create_cross_backend_global_setup (in global_setup.ts) reads the project's name to pick which BackendConfig to spawn, so the project name is the single source of truth for backend selection.

Consumers compose these into their vite.config.ts:

const cross_backend_projects = process.env.FUZ_TEST_CROSS_BACKEND ? [ make_cross_backend_project({name: 'cross_backend_ts_deno', global_setup: GLOBAL_SETUP}), make_cross_backend_project({name: 'cross_backend_rust', global_setup: GLOBAL_SETUP}), ] : [];

where GLOBAL_SETUP = './src/test/cross_backend/global_setup.ts'.

This module is intentionally dependency-free and assert_dev_env-free: it runs at vite config time (including production builds, where the consumer gates the projects behind an env flag), so it must not pull in the DEV-only test runtime.

view source

Declarations
#

2 declarations

CrossBackendProjectOptions
#

testing/cross_backend/make_cross_backend_project.ts view source

CrossBackendProjectOptions import type {CrossBackendProjectOptions} from '@fuzdev/fuz_app/testing/cross_backend/make_cross_backend_project.js';

name

vitest project name. create_cross_backend_global_setup derives the backend name from it (by default stripping a cross_backend_(ts_)? prefix), so name projects cross_backend_<backend> (e.g. cross_backend_rust, cross_backend_ts_deno).

type string

readonly

global_setup

Path to the consumer's vitest globalSetup module, relative to the consumer repo root (e.g. './src/test/cross_backend/global_setup.ts'). That module is expected to export a create_cross_backend_global_setup result as its default.

type string

readonly

include?

Test-file globs. Default: ['src/test/cross_backend/*.cross.test.ts'].

type ReadonlyArray<string>

readonly

exclude?

Globs to exclude from include (e.g. a backend-specific variant file). Default: [].

type ReadonlyArray<string>

readonly

group_order?

vitest sequence.groupOrder. Default: 3 (runs after unit + db).

type number

readonly

make_cross_backend_project
#

testing/cross_backend/make_cross_backend_project.ts view source

({ name, global_setup, include, exclude, group_order, }: CrossBackendProjectOptions): { extends: true; test: { name: string; include: string[]; exclude: string[]; globalSetup: string[]; isolate: false; fileParallelism: false; sequence: { ...; }; }; } import {make_cross_backend_project} from '@fuzdev/fuz_app/testing/cross_backend/make_cross_backend_project.js';

Build a single cross-backend vitest project config. Spread the results into test.projects in the consumer's vite.config.ts. isolate: false + fileParallelism: false because a project shares one spawned backend across its files.

__0

returns

{ extends: true; test: { name: string; include: string[]; exclude: string[]; globalSetup: string[]; isolate: false; fileParallelism: false; sequence: { groupOrder: number; }; }; }