Files
tkmind_go/ui/goose2/tests/app-e2e/lib/setup.ts
T
Jack Amadeo 482f1962c1 Move goose2 (#8516)
Signed-off-by: Jack Amadeo <jackamadeo@squareup.com>
Co-authored-by: block-open-source[bot] <201011344+block-open-source[bot]@users.noreply.github.com>
Co-authored-by: block-open-source[bot] <1159699+block-open-source[bot]@users.noreply.github.com>
Co-authored-by: Wes <wesbillman@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Matt Toohey <contact@matttoohey.com>
Co-authored-by: tulsi <tulsi@block.xyz>
Co-authored-by: morgmart <98432065+morgmart@users.noreply.github.com>
Co-authored-by: Bradley Axen <baxen@squareup.com>
Co-authored-by: Alex Hancock <alexhancock@block.xyz>
Co-authored-by: Taylor Ho <taylorkmho@gmail.com>
Co-authored-by: Nahiyan Khan <nahiyan.khan@gmail.com>
Co-authored-by: Lifei Zhou <lifei@squareup.com>
2026-04-14 14:39:30 +00:00

42 lines
1.1 KiB
TypeScript

import { beforeAll, beforeEach, afterAll, onTestFailed } from "vitest";
import { type TestDriver, createTestDriver } from "./test-driver-client";
declare const __SCREENSHOT_DIR__: string;
declare const __SCREENSHOT_ON_FAILURE__: boolean;
export const useTestDriver = (): TestDriver => {
let inner: TestDriver;
const testDriver = new Proxy({} as TestDriver, {
get(_target, prop) {
if (!inner)
throw new Error("Test driver not connected — is beforeAll running?");
return inner[prop as keyof TestDriver];
},
});
beforeAll(async () => {
inner = await createTestDriver();
});
afterAll(() => {
inner?.close();
});
beforeEach(async () => {
// Navigate to home before each test for clean state
await inner.click('[data-testid="nav-home"]');
if (__SCREENSHOT_ON_FAILURE__) {
onTestFailed(async ({ task }) => {
const name = task.name.replace(/\s+/g, "-").toLowerCase();
const path = `${__SCREENSHOT_DIR__}/fail-${name}-${Date.now()}.png`;
await inner.screenshot(path);
console.log(`Screenshot saved: ${path}`);
});
}
});
return testDriver;
};