39 lines
1.5 KiB
TypeScript
39 lines
1.5 KiB
TypeScript
|
|
// This file is auto-generated by alef — DO NOT EDIT.
|
||
|
|
// alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
|
||
|
|
// To regenerate: alef generate
|
||
|
|
// To verify freshness: alef verify --exit-code
|
||
|
|
// Issues & docs: https://github.com/kreuzberg-dev/alef
|
||
|
|
import { fileURLToPath } from 'url';
|
||
|
|
import { dirname, join } from 'path';
|
||
|
|
import { existsSync } from 'fs';
|
||
|
|
|
||
|
|
// Change to the configured test-documents directory so that fixture file
|
||
|
|
// paths like "pdf/fake_memo.pdf" resolve correctly when running vitest
|
||
|
|
// from e2e/node/. setup.ts lives in e2e/node/; the fixtures dir lives at
|
||
|
|
// the repository root, two directories up: e2e/node/ -> e2e/ -> root.
|
||
|
|
const __filename = fileURLToPath(import.meta.url);
|
||
|
|
const __dirname = dirname(__filename);
|
||
|
|
const testDocumentsDir = join(__dirname, '..', '..', 'test_documents');
|
||
|
|
|
||
|
|
// Validate that the test documents directory exists before changing into it.
|
||
|
|
// If it doesn't exist, log the error to stderr so the before hook failure
|
||
|
|
// is visible rather than failing silently.
|
||
|
|
if (!existsSync(testDocumentsDir)) {
|
||
|
|
console.error(
|
||
|
|
`[E2E Setup] test_documents directory not found: ${testDocumentsDir}\n` +
|
||
|
|
`Check that alef.toml [crates.e2e] test_documents_dir is configured correctly.\n` +
|
||
|
|
`Fixture file paths will not resolve correctly.`
|
||
|
|
);
|
||
|
|
process.exit(1);
|
||
|
|
}
|
||
|
|
|
||
|
|
try {
|
||
|
|
process.chdir(testDocumentsDir);
|
||
|
|
} catch (error) {
|
||
|
|
console.error(`[E2E Setup] Failed to change directory to ${testDocumentsDir}: ${error}`);
|
||
|
|
process.exit(1);
|
||
|
|
}
|
||
|
|
|
||
|
|
// Mark this file as a module so vitest recognizes the setup
|
||
|
|
export {};
|