Files
Kmake/test/fixtures/test-runner/global-setup-teardown/basic-setup-teardown.ts
2026-05-26 23:36:42 -07:00

25 lines
666 B
TypeScript

import * as fs from 'node:fs';
// Path for temporary file to track execution
const setupFlagPath = process.env.SETUP_FLAG_PATH;
const teardownFlagPath = process.env.TEARDOWN_FLAG_PATH;
async function globalSetup(): Promise<void> {
console.log('Global setup executed');
if (setupFlagPath) {
fs.writeFileSync(setupFlagPath, 'Setup was executed');
}
}
async function globalTeardown(): Promise<void> {
console.log('Global teardown executed');
if (teardownFlagPath) {
fs.writeFileSync(teardownFlagPath, 'Teardown was executed');
}
if (setupFlagPath) {
fs.rmSync(setupFlagPath, { force: true });
}
}
export { globalSetup, globalTeardown };