| 1 |
import '@testing-library/jest-dom/vitest'; |
| 2 |
|
| 3 |
// XSpeedConfig is normally injected by wp_localize_script. In Vitest we |
| 4 |
// shim a sensible default so components that read window.XSpeedConfig |
| 5 |
// during render don't blow up. Individual tests override with stronger |
| 6 |
// fixtures via vi.stubGlobal('XSpeedConfig', { ... }) as needed. |
| 7 |
declare global { |
| 8 |
interface Window { |
| 9 |
XSpeedConfig: { |
| 10 |
mode?: 'dashboard' | 'onboarding'; |
| 11 |
restUrl: string; |
| 12 |
nonce: string; |
| 13 |
version: string; |
| 14 |
dashboardUrl?: string; |
| 15 |
bootstrap?: any; |
| 16 |
}; |
| 17 |
} |
| 18 |
} |
| 19 |
|
| 20 |
if (typeof window !== 'undefined') { |
| 21 |
window.XSpeedConfig = window.XSpeedConfig ?? { |
| 22 |
restUrl: 'http://localhost/wp-json/xspeed/v1', |
| 23 |
nonce: 'test-nonce', |
| 24 |
version: '1.0.0-test', |
| 25 |
}; |
| 26 |
} |
| 27 |
|