Skip to content

Commit

Permalink
Add Jest setup file with proper mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
amiable-dev committed Dec 3, 2024
1 parent 464a713 commit 7ce5e66
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions jest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import '@testing-library/jest-dom';
import {jest} from '@jest/globals';

// Mock window.matchMedia
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation(query => ({
matches: false,
media: query,
onchange: null,
addListener: jest.fn(),
removeListener: jest.fn(),
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
})),
});

// Mock Docusaurus context
Object.defineProperty(window, 'docusaurus', {
value: {
prefetch: jest.fn(),
preload: jest.fn(),
},
configurable: true,
});

0 comments on commit 7ce5e66

Please sign in to comment.