forked from dBildungsplattform/schulportal-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vitest.setup.ts
54 lines (44 loc) · 1.46 KB
/
vitest.setup.ts
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { config } from '@vue/test-utils';
import { I18n, createI18n } from 'vue-i18n';
import { createVuetify } from 'vuetify';
import { afterAll, afterEach, beforeAll } from 'vitest';
import { TestingPinia, createTestingPinia } from '@pinia/testing';
// MSW will probably be removed soon anyways
// eslint-disable-next-line import/no-extraneous-dependencies, import/named
import { SetupServer, setupServer } from 'msw/node';
import requestHandlers from './src/specs/request-handlers';
import de_locales from './src/locales/de-DE.json';
const i18n: I18n = createI18n({
fallbackLocale: 'de',
legacy: false,
locale: 'de',
messages: {
de: de_locales,
},
});
// eslint-disable-next-line @typescript-eslint/typedef
const vuetify = createVuetify({});
const pinia: TestingPinia = createTestingPinia();
/* Setup mock server */
const server: SetupServer = setupServer(...requestHandlers);
/* Start mock server before all tests */
beforeAll(() => {
server.listen({ onUnhandledRequest: 'error' });
// @ts-ignore:
global.ResizeObserver = class ResizeObserver {
public observe(): void {
// do nothing
}
public unobserve(): void {
// do nothing
}
public disconnect(): void {
// do nothing
}
};
});
/* Close mock server after all tests */
afterAll(() => server.close());
/* Reset request handlers after each test => `important for test isolation` */
afterEach(() => server.resetHandlers());
config.global.plugins = [i18n, pinia, vuetify];