Initial Commit

This commit is contained in:
2026-05-27 23:29:53 +01:00
commit fbc70f96e6
10000 changed files with 1102152 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
/**
* Shared integration-setup module — exposes the typed `inject` helper and a
* `surrealUnavailable` boolean for `describe.skipIf(...)` skip-when-down
* behaviour. Fixture registration happens in the sibling `global-setup.ts`
* file because vitest runs `globalSetup` in a separate process from the
* worker pool.
*
* @module
*/
import { inject as vitestInject } from "@suaveplan/testing/runner";
import type { SurrealDBConfig } from "@suaveplan/testing-integration-surrealdb";
interface IntegrationConfigs {
surrealdb: SurrealDBConfig;
}
export function inject<K extends keyof IntegrationConfigs>(
key: K
): IntegrationConfigs[K] {
const all = (vitestInject as (k: string) => IntegrationConfigs)(
"__integration_configs__"
);
return all[key];
}
/**
* `true` when the SurrealDB fixture failed to start (no Docker, env-bridge
* incomplete) or when the test runs outside the integration config (no
* globalSetup at all). Test files use this with `describe.skipIf(...)` so
* the suite SKIPS rather than FAILS.
*/
export const surrealUnavailable: boolean = (() => {
try {
const failed = (vitestInject as (k: string) => string[] | undefined)(
"__integration_failed__"
);
if (failed === undefined) return true;
if (failed.includes("surrealdb")) return true;
const configs = (
vitestInject as (
k: string
) => Record<string, Record<string, unknown>> | undefined
)("__integration_configs__");
return configs === undefined || configs.surrealdb === undefined;
} catch {
return true;
}
})();