brand new unit tests finally
Some checks failed
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Failing after 2m8s
Some checks failed
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Failing after 2m8s
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)),
|
||||
},
|
||||
}));
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user