34 lines
785 B
TypeScript
34 lines
785 B
TypeScript
import * as dotenv from 'dotenv';
|
|
|
|
// Load environment variables for testing
|
|
dotenv.config({ path: '.env.test' });
|
|
|
|
// Suppress console logs during tests unless DEBUG is set
|
|
if (!process.env.DEBUG) {
|
|
global.console = {
|
|
...console,
|
|
log: jest.fn(),
|
|
debug: jest.fn(),
|
|
info: jest.fn(),
|
|
warn: jest.fn(),
|
|
};
|
|
}
|
|
|
|
// Global test timeout
|
|
jest.setTimeout(10000);
|
|
|
|
// Add custom matchers if needed
|
|
expect.extend({
|
|
toBeValidUUID(received: string) {
|
|
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
const pass = uuidRegex.test(received);
|
|
|
|
return {
|
|
pass,
|
|
message: () =>
|
|
pass
|
|
? `Expected ${received} not to be a valid UUID`
|
|
: `Expected ${received} to be a valid UUID`
|
|
};
|
|
}
|
|
}); |