# xspeed/1.0.1/tests-js/setup.ts

xSpeed Cache: AI-Powered Performance Hub with MCP, Caching &amp; CDN, version 1.0.1. 27 lines.

- Page: https://pluginprobe.com/plugins/xspeed/1.0.1/code/tests-js/setup.ts
- Raw: https://pluginprobe.com/plugins/xspeed/1.0.1/raw/tests-js/setup.ts
- Modified: 2026-06-01T17:33:22+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/xspeed/1.0.1/code/tests-js/setup.ts#L10-L20`.

```typescript
import '@testing-library/jest-dom/vitest';

// XSpeedConfig is normally injected by wp_localize_script. In Vitest we
// shim a sensible default so components that read window.XSpeedConfig
// during render don't blow up. Individual tests override with stronger
// fixtures via vi.stubGlobal('XSpeedConfig', { ... }) as needed.
declare global {
  interface Window {
    XSpeedConfig: {
      mode?: 'dashboard' | 'onboarding';
      restUrl: string;
      nonce: string;
      version: string;
      dashboardUrl?: string;
      bootstrap?: any;
    };
  }
}

if (typeof window !== 'undefined') {
  window.XSpeedConfig = window.XSpeedConfig ?? {
    restUrl: 'http://localhost/wp-json/xspeed/v1',
    nonce: 'test-nonce',
    version: '1.0.0-test',
  };
}

```
