tstest/test/config-test/test.config.ts

44 lines
1.4 KiB
TypeScript

import { tap, expect } from '../../ts_tapbundle/index.js';
// TAP-compliant comment output
console.log('# 🔍 TEST FILE LOADED - test.config.ts');
// Check if 00init.ts was loaded
const initLoaded = (global as any).__00INIT_LOADED;
console.log(`# 🔍 00init.ts loaded: ${initLoaded === true}`);
// Test that uses the global timeout setting
tap.test('Test with global timeout', async (toolsArg) => {
// This test should complete within the 5 second timeout set in 00init.ts
await toolsArg.delayFor(2000); // 2 seconds
expect(true).toBeTrue();
});
// Test that demonstrates retries
tap.test('Test with retries', async () => {
// This test will use the global retry setting (2 retries)
console.log('Running test that might be flaky');
// Simulate a flaky test that passes on second try
const randomValue = Math.random();
console.log(`Random value: ${randomValue}`);
// Always pass for demonstration
expect(true).toBeTrue();
});
// Test with custom timeout that overrides global
tap.timeout(1000).test('Test with custom timeout', async (toolsArg) => {
// This test has a 1 second timeout, overriding the global 5 seconds
await toolsArg.delayFor(500); // 500ms - should pass
expect(true).toBeTrue();
});
// Test to verify lifecycle hooks are working
tap.test('Test lifecycle hooks', async () => {
console.log('Inside test: lifecycle hooks should have run');
expect(true).toBeTrue();
});
// Start the test suite
tap.start();