-
Notifications
You must be signed in to change notification settings - Fork 144
Expand file tree
/
Copy pathvitest-setup.ts
More file actions
38 lines (31 loc) · 861 Bytes
/
vitest-setup.ts
File metadata and controls
38 lines (31 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import i18next from 'i18next';
import { vi } from 'vitest';
import { i18nNamespaces } from './src/lib/i18n';
import resources from './src/lib/i18n/locales';
i18next.init({
fallbackLng: 'en',
load: 'languageOnly',
ns: i18nNamespaces,
defaultNS: 'common',
detection: {
order: ['querystring', 'localStorage', 'navigator'],
caches: ['localStorage'],
lookupQuerystring: 'lng',
lookupLocalStorage: 'locale',
},
resources,
});
const BroadcastChannelMock = vi.fn(() => ({
addEventListener: () => {},
postMessage: () => {},
}));
vi.stubGlobal('BroadcastChannel', BroadcastChannelMock);
const cryptoMock = {
randomUUID: () => 'test-uuid-' + Math.random().toString(36).substring(2, 9),
};
vi.stubGlobal('crypto', cryptoMock);
vi.mock('esm-env', () => {
const BROWSER = true;
const DEV = false;
return { BROWSER, DEV };
});