-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest-setup.js
50 lines (46 loc) · 1.04 KB
/
jest-setup.js
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
import '@testing-library/jest-dom';
import Vue from 'vue';
import { config } from '@vue/test-utils';
config.stubs = {
NuxtImg: { render(h) { return h('img'); } },
};
config.mocks = {
$t: (text) => text,
$fc: (text) => text,
localePath: (text) => text,
localeRouter: (route) => route,
};
const $vsf = {
$magento: {
config: {
imageProvider: '',
magentoBaseUrl: '',
state: {
getMessage: jest.fn(),
},
},
},
};
// mocks object returned by useContext()
Vue.prototype.$nuxt = {
context: {
$vsf,
$fc: jest.fn((label) => label),
localeRoute: jest.fn((route) => route),
localePath: jest.fn((link) => link),
app: {
// $vsf intentionally doubled in context top level AND in context.app - this is the way it's in the app
$vsf,
context: {
$vsf,
},
$fc: jest.fn((label) => label),
localePath: jest.fn((link) => link),
localeRoute: jest.fn((path) => path),
},
i18n: {
t: jest.fn((label) => label),
},
},
};
Vue.directive('e2e', {});