Some checks failed
CI / lint-typecheck (pull_request) Failing after 4m51s
CI / tests (pull_request) Has been skipped
CI / contract-tests (pull_request) Has been skipped
CI / e2e-tests (pull_request) Has been skipped
CI / comment-pr (pull_request) Has been skipped
CI / commit-types (pull_request) Has been skipped
76 lines
1.5 KiB
TypeScript
76 lines
1.5 KiB
TypeScript
import { beforeAll, afterAll, beforeEach, afterEach } from 'vitest';
|
|
import { IntegrationTestHarness, createTestHarness } from './index';
|
|
import { ApiClient } from './api-client';
|
|
import { DatabaseManager } from './database-manager';
|
|
import { DataFactory } from './data-factory';
|
|
|
|
/**
|
|
* Shared test context for harness-related integration tests.
|
|
* Provides a DRY setup for tests that verify the harness infrastructure itself.
|
|
*/
|
|
export class HarnessTestContext {
|
|
private harness: IntegrationTestHarness;
|
|
|
|
constructor() {
|
|
this.harness = createTestHarness();
|
|
}
|
|
|
|
get api(): ApiClient {
|
|
return this.harness.getApi();
|
|
}
|
|
|
|
get db(): DatabaseManager {
|
|
return this.harness.getDatabase();
|
|
}
|
|
|
|
get factory(): DataFactory {
|
|
return this.harness.getFactory();
|
|
}
|
|
|
|
get testHarness(): IntegrationTestHarness {
|
|
return this.harness;
|
|
}
|
|
|
|
/**
|
|
* Standard setup for harness tests
|
|
*/
|
|
async setup() {
|
|
await this.harness.beforeAll();
|
|
}
|
|
|
|
/**
|
|
* Standard teardown for harness tests
|
|
*/
|
|
async teardown() {
|
|
await this.harness.afterAll();
|
|
}
|
|
|
|
/**
|
|
* Standard per-test setup
|
|
*/
|
|
async reset() {
|
|
await this.harness.beforeEach();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Helper to create and register a HarnessTestContext with Vitest hooks
|
|
*/
|
|
export function setupHarnessTest() {
|
|
const context = new HarnessTestContext();
|
|
|
|
beforeAll(async () => {
|
|
await context.setup();
|
|
});
|
|
|
|
afterAll(async () => {
|
|
await context.teardown();
|
|
});
|
|
|
|
beforeEach(async () => {
|
|
await context.reset();
|
|
});
|
|
|
|
return context;
|
|
}
|