brand new unit tests finally
Some checks failed
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Failing after 2m8s

This commit is contained in:
2025-11-28 09:11:31 -08:00
parent 8fd7bb7a0b
commit aff6e2df55
3 changed files with 19 additions and 7 deletions

View File

@@ -20,9 +20,12 @@ describe('VoiceLabPage', () => {
mockAudioPlay.mockResolvedValue(undefined);
// Mock the global Audio constructor
const AudioMock = vi.fn().mockImplementation(() => ({
play: mockAudioPlay,
}));
const AudioMock = vi.fn().mockImplementation((url) => {
console.log('AudioMock instantiated with:', url); // Debug log
return {
play: mockAudioPlay,
};
});
vi.stubGlobal('Audio', AudioMock);
// Explicitly stub window.Audio as well for JSDOM environments

View File

@@ -19,11 +19,13 @@ vi.mock('nodemailer', () => {
});
// Mock the logger to prevent console output during tests
// Mock the logger to prevent console output during tests, but allow errors to show for debugging
vi.mock('./logger.server', () => ({
logger: {
info: vi.fn(),
debug: vi.fn(),
error: vi.fn(),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
error: vi.fn((msg, meta) => console.error('[MOCK LOGGER ERROR]', msg, meta)),
},
}));

View File

@@ -8,9 +8,16 @@ const errorMock = vi.fn();
// Mock react-hot-toast
vi.mock('react-hot-toast', () => {
const toast = vi.fn() as any;
toast.success = successMock;
toast.error = errorMock;
// Create a function that can also have properties
const toastFn = vi.fn();
// Attach methods to the function to mimic the library's default export
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const toast = Object.assign(toastFn, {
success: (...args: any[]) => successMock(...args),
error: (...args: any[]) => errorMock(...args),
});
return {
default: toast,
toast,