WIP: feat: update_vitest_version to 2.0.0 #1127
|
@ -51,7 +51,7 @@
|
||||||
"husky": "^8.0.0",
|
"husky": "^8.0.0",
|
||||||
"postcss": "^8.4.23",
|
"postcss": "^8.4.23",
|
||||||
"prettier": "^2.8.8",
|
"prettier": "^2.8.8",
|
||||||
"vitest": "^0.31.1"
|
"vitest": "^2.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^20 || ^18 || ^16",
|
"node": "^20 || ^18 || ^16",
|
||||||
|
|
668
pnpm-lock.yaml
668
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,6 @@
|
||||||
import { vi, describe, expect, it, beforeAll } from 'vitest';
|
import { vi, describe, expect, it, beforeAll } from 'vitest';
|
||||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
import axios from 'axios';
|
||||||
|
import { createWrapper } from 'app/test/vitest/helper';
|
||||||
import Leftmenu from 'components/LeftMenu.vue';
|
import Leftmenu from 'components/LeftMenu.vue';
|
||||||
|
|
||||||
import { useNavigationStore } from 'src/stores/useNavigationStore';
|
import { useNavigationStore } from 'src/stores/useNavigationStore';
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
import axios from 'axios';
|
||||||
|
import { createWrapper } from 'app/test/vitest/helper';
|
||||||
import VnChangePassword from 'src/components/common/VnChangePassword.vue';
|
import VnChangePassword from 'src/components/common/VnChangePassword.vue';
|
||||||
import { vi, beforeEach, afterEach, beforeAll, describe, expect, it } from 'vitest';
|
import { vi, beforeEach, afterEach, beforeAll, describe, expect, it } from 'vitest';
|
||||||
import { Notify } from 'quasar';
|
import { Notify } from 'quasar';
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
||||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
import axios from 'axios';
|
||||||
|
import { createWrapper } from 'app/test/vitest/helper';
|
||||||
import VnLog from 'src/components/common/VnLog.vue';
|
import VnLog from 'src/components/common/VnLog.vue';
|
||||||
|
|
||||||
describe('VnLog', () => {
|
describe('VnLog', () => {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
||||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
import axios from 'axios';
|
||||||
|
import { createWrapper } from 'app/test/vitest/helper';
|
||||||
import VnPaginate from 'src/components/ui/VnPaginate.vue';
|
import VnPaginate from 'src/components/ui/VnPaginate.vue';
|
||||||
|
|
||||||
describe('VnPaginate', () => {
|
describe('VnPaginate', () => {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { describe, it, expect, beforeAll, vi } from 'vitest';
|
import { describe, it, expect, beforeAll, vi } from 'vitest';
|
||||||
import { axios } from 'app/test/vitest/helper';
|
import axios from 'axios';
|
||||||
import parsePhone from 'src/filters/parsePhone';
|
import parsePhone from 'src/filters/parsePhone';
|
||||||
|
|
||||||
describe('parsePhone filter', () => {
|
describe('parsePhone filter', () => {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
||||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
import axios from 'axios';
|
||||||
|
import { createWrapper } from 'app/test/vitest/helper';
|
||||||
import VnSms from 'src/components/ui/VnSms.vue';
|
import VnSms from 'src/components/ui/VnSms.vue';
|
||||||
|
|
||||||
describe('VnSms', () => {
|
describe('VnSms', () => {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { vi, describe, expect, it, beforeAll, afterAll } from 'vitest';
|
import { vi, describe, expect, it, beforeAll, afterAll } from 'vitest';
|
||||||
import { axios } from 'app/test/vitest/helper';
|
import axios from 'axios';
|
||||||
import { downloadFile } from 'src/composables/downloadFile';
|
import { downloadFile } from 'src/composables/downloadFile';
|
||||||
import { useSession } from 'src/composables/useSession';
|
import { useSession } from 'src/composables/useSession';
|
||||||
const session = useSession();
|
const session = useSession();
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import { vi, describe, expect, it, beforeAll, afterAll } from 'vitest';
|
import { vi, describe, expect, it, beforeAll, afterAll } from 'vitest';
|
||||||
import { axios, flushPromises } from 'app/test/vitest/helper';
|
import axios from 'axios';
|
||||||
|
|
||||||
|
import { flushPromises } from '@vue/test-utils';
|
||||||
import { useAcl } from 'src/composables/useAcl';
|
import { useAcl } from 'src/composables/useAcl';
|
||||||
|
|
||||||
describe('useAcl', () => {
|
describe('useAcl', () => {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { describe, expect, it, beforeEach, afterEach, vi } from 'vitest';
|
import { describe, expect, it, beforeEach, afterEach, vi } from 'vitest';
|
||||||
import { axios, flushPromises } from 'app/test/vitest/helper';
|
import axios from 'axios';
|
||||||
|
import { flushPromises } from 'app/test/vitest/helper';
|
||||||
import { useArrayData } from 'composables/useArrayData';
|
import { useArrayData } from 'composables/useArrayData';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import * as vueRouter from 'vue-router';
|
import * as vueRouter from 'vue-router';
|
||||||
|
@ -25,8 +26,8 @@ describe('useArrayData', () => {
|
||||||
arrayData.fetch({});
|
arrayData.fetch({});
|
||||||
|
|
||||||
await flushPromises();
|
await flushPromises();
|
||||||
const routerReplace = useRouter().replace.mock.calls[0][0];
|
let routerReplace = useRouter().replace;
|
||||||
|
routerReplace = routerReplace.mock.calls[0][0];
|
||||||
expect(axios.get.mock.calls[0][1].params).toEqual({
|
expect(axios.get.mock.calls[0][1].params).toEqual({
|
||||||
filter,
|
filter,
|
||||||
supplierFk: 2,
|
supplierFk: 2,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { vi, describe, expect, it } from 'vitest';
|
import { vi, describe, expect, it } from 'vitest';
|
||||||
import { axios, flushPromises } from 'app/test/vitest/helper';
|
import axios from 'axios';
|
||||||
|
import { flushPromises } from '@vue/test-utils';
|
||||||
import { useRole } from 'composables/useRole';
|
import { useRole } from 'composables/useRole';
|
||||||
const role = useRole();
|
const role = useRole();
|
||||||
|
|
||||||
|
@ -31,10 +32,9 @@ describe('useRole', () => {
|
||||||
lang: 'en',
|
lang: 'en',
|
||||||
};
|
};
|
||||||
const expectedRoles = ['salesPerson', 'admin'];
|
const expectedRoles = ['salesPerson', 'admin'];
|
||||||
vi.spyOn(axios, 'get')
|
vi.spyOn(axios, 'get').mockResolvedValueOnce({
|
||||||
.mockResolvedValueOnce({
|
|
||||||
data: { roles: rolesData, user: fetchedUser },
|
data: { roles: rolesData, user: fetchedUser },
|
||||||
})
|
});
|
||||||
|
|
||||||
vi.spyOn(role.state, 'setUser');
|
vi.spyOn(role.state, 'setUser');
|
||||||
vi.spyOn(role.state, 'setRoles');
|
vi.spyOn(role.state, 'setRoles');
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { vi, describe, expect, it, beforeAll, beforeEach } from 'vitest';
|
import { vi, describe, expect, it, beforeAll, beforeEach } from 'vitest';
|
||||||
import { axios } from 'app/test/vitest/helper';
|
import axios from 'axios';
|
||||||
import { useSession } from 'composables/useSession';
|
import { useSession } from 'composables/useSession';
|
||||||
import { useState } from 'composables/useState';
|
import { useState } from 'composables/useState';
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { vi, describe, expect, it } from 'vitest';
|
import { vi, describe, expect, it } from 'vitest';
|
||||||
import { axios, flushPromises } from 'app/test/vitest/helper';
|
import axios from 'axios';
|
||||||
|
import { flushPromises } from '@vue/test-utils';
|
||||||
import { useTokenConfig } from 'composables/useTokenConfig';
|
import { useTokenConfig } from 'composables/useTokenConfig';
|
||||||
const tokenConfig = useTokenConfig();
|
const tokenConfig = useTokenConfig();
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
||||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
import axios from 'axios';
|
||||||
|
import { createWrapper } from 'app/test/vitest/helper';
|
||||||
import ClaimDescriptorMenu from 'pages/Claim/Card/ClaimDescriptorMenu.vue';
|
import ClaimDescriptorMenu from 'pages/Claim/Card/ClaimDescriptorMenu.vue';
|
||||||
|
|
||||||
describe('ClaimDescriptorMenu', () => {
|
describe('ClaimDescriptorMenu', () => {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { vi, describe, expect, it, beforeAll, beforeEach, afterEach } from 'vitest';
|
import { vi, describe, expect, it, beforeAll, beforeEach, afterEach } from 'vitest';
|
||||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
import axios from 'axios';
|
||||||
|
import { createWrapper } from 'app/test/vitest/helper';
|
||||||
import ClaimLines from '/src/pages/Claim/Card/ClaimLines.vue';
|
import ClaimLines from '/src/pages/Claim/Card/ClaimLines.vue';
|
||||||
|
|
||||||
describe('ClaimLines', () => {
|
describe('ClaimLines', () => {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { vi, describe, expect, it, beforeAll, beforeEach, afterEach } from 'vitest';
|
import { vi, describe, expect, it, beforeAll, beforeEach, afterEach } from 'vitest';
|
||||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
import axios from 'axios';
|
||||||
|
import { createWrapper } from 'app/test/vitest/helper';
|
||||||
import ClaimLinesImport from 'pages/Claim/Card/ClaimLinesImport.vue';
|
import ClaimLinesImport from 'pages/Claim/Card/ClaimLinesImport.vue';
|
||||||
|
|
||||||
describe('ClaimLinesImport', () => {
|
describe('ClaimLinesImport', () => {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
||||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
import axios from 'axios';
|
||||||
|
import { createWrapper } from 'app/test/vitest/helper';
|
||||||
import ClaimPhoto from 'pages/Claim/Card/ClaimPhoto.vue';
|
import ClaimPhoto from 'pages/Claim/Card/ClaimPhoto.vue';
|
||||||
|
|
||||||
describe('ClaimPhoto', () => {
|
describe('ClaimPhoto', () => {
|
||||||
let vm;
|
let vm;
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ describe('ClaimPhoto', () => {
|
||||||
title: 'This file will be deleted',
|
title: 'This file will be deleted',
|
||||||
icon: 'delete',
|
icon: 'delete',
|
||||||
data: { index: 1 },
|
data: { index: 1 },
|
||||||
promise: vm.deleteDms
|
promise: vm.deleteDms,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
||||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
import axios from 'axios';
|
||||||
|
import { createWrapper } from 'app/test/vitest/helper';
|
||||||
import CustomerPayments from 'src/pages/Customer/Payments/CustomerPayments.vue';
|
import CustomerPayments from 'src/pages/Customer/Payments/CustomerPayments.vue';
|
||||||
|
|
||||||
describe('CustomerPayments', () => {
|
describe('CustomerPayments', () => {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
||||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
import { createWrapper } from 'app/test/vitest/helper';
|
||||||
import Login from 'pages/Login/LoginMain.vue';
|
import Login from 'pages/Login/LoginMain.vue';
|
||||||
|
import axios from 'axios';
|
||||||
|
|
||||||
describe('Login', () => {
|
describe('Login', () => {
|
||||||
let vm;
|
let vm;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
||||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
import axios from 'axios';
|
||||||
|
import { createWrapper } from 'app/test/vitest/helper';
|
||||||
import TicketBoxing from 'pages/Ticket/Card/TicketBoxing.vue';
|
import TicketBoxing from 'pages/Ticket/Card/TicketBoxing.vue';
|
||||||
|
|
||||||
// #4836 - Investigate how to test q-drawer outside
|
// #4836 - Investigate how to test q-drawer outside
|
||||||
|
@ -21,7 +22,11 @@ describe('TicketBoxing', () => {
|
||||||
min: 1,
|
min: 1,
|
||||||
max: 2,
|
max: 2,
|
||||||
};
|
};
|
||||||
const videoList = ['2022-01-01T01-01-00.mp4', '2022-02-02T02-02-00.mp4', '2022-03-03T03-03-00.mp4'];
|
const videoList = [
|
||||||
|
'2022-01-01T01-01-00.mp4',
|
||||||
|
'2022-02-02T02-02-00.mp4',
|
||||||
|
'2022-03-03T03-03-00.mp4',
|
||||||
|
];
|
||||||
|
|
||||||
vi.spyOn(axios, 'get').mockResolvedValue({ data: videoList });
|
vi.spyOn(axios, 'get').mockResolvedValue({ data: videoList });
|
||||||
vi.spyOn(vm.quasar, 'notify');
|
vi.spyOn(vm.quasar, 'notify');
|
||||||
|
@ -44,7 +49,9 @@ describe('TicketBoxing', () => {
|
||||||
|
|
||||||
await vm.getVideoList(expeditionId, timed);
|
await vm.getVideoList(expeditionId, timed);
|
||||||
|
|
||||||
expect(vm.quasar.notify).toHaveBeenCalledWith(expect.objectContaining({ type: 'negative' }));
|
expect(vm.quasar.notify).toHaveBeenCalledWith(
|
||||||
|
expect.objectContaining({ type: 'negative' })
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { vi, describe, expect, it, beforeAll, afterEach, beforeEach } from 'vitest';
|
import { vi, describe, expect, it, beforeAll, afterEach, beforeEach } from 'vitest';
|
||||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
import axios from 'axios';
|
||||||
|
import { createWrapper } from 'app/test/vitest/helper';
|
||||||
import TicketAdvance from 'pages/Ticket/TicketAdvance.vue';
|
import TicketAdvance from 'pages/Ticket/TicketAdvance.vue';
|
||||||
import { Notify } from 'quasar';
|
import { Notify } from 'quasar';
|
||||||
import { nextTick } from 'vue';
|
import { nextTick } from 'vue';
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
|
||||||
import { createWrapper, axios } from 'app/test/vitest/helper';
|
import axios from 'axios';
|
||||||
|
import { createWrapper } from 'app/test/vitest/helper';
|
||||||
import WagonCreate from 'pages/Wagon/WagonCreate.vue';
|
import WagonCreate from 'pages/Wagon/WagonCreate.vue';
|
||||||
|
|
||||||
describe('WagonCreate', () => {
|
describe('WagonCreate', () => {
|
||||||
|
|
|
@ -4,7 +4,6 @@ import { createTestingPinia } from '@pinia/testing';
|
||||||
import { vi } from 'vitest';
|
import { vi } from 'vitest';
|
||||||
import { i18n } from 'src/boot/i18n';
|
import { i18n } from 'src/boot/i18n';
|
||||||
import { Notify, Dialog } from 'quasar';
|
import { Notify, Dialog } from 'quasar';
|
||||||
import axios from 'axios';
|
|
||||||
import * as useValidator from 'src/composables/useValidator';
|
import * as useValidator from 'src/composables/useValidator';
|
||||||
|
|
||||||
installQuasarPlugin({
|
installQuasarPlugin({
|
||||||
|
@ -14,35 +13,6 @@ installQuasarPlugin({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const pinia = createTestingPinia({ createSpy: vi.fn, stubActions: false });
|
const pinia = createTestingPinia({ createSpy: vi.fn, stubActions: false });
|
||||||
const mockPush = vi.fn();
|
|
||||||
const mockReplace = vi.fn();
|
|
||||||
|
|
||||||
vi.mock('vue-router', () => ({
|
|
||||||
useRouter: () => ({
|
|
||||||
push: mockPush,
|
|
||||||
replace: mockReplace,
|
|
||||||
currentRoute: {
|
|
||||||
value: {
|
|
||||||
params: {
|
|
||||||
id: 1,
|
|
||||||
},
|
|
||||||
meta: { moduleName: 'mockName' },
|
|
||||||
matched: [{ path: 'mockName/list' }],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
useRoute: () => ({
|
|
||||||
matched: [],
|
|
||||||
query: {},
|
|
||||||
params: {},
|
|
||||||
meta: { moduleName: 'mockName' },
|
|
||||||
path: 'mockSection/list',
|
|
||||||
}),
|
|
||||||
onBeforeRouteLeave: () => {},
|
|
||||||
}));
|
|
||||||
|
|
||||||
vi.mock('axios');
|
|
||||||
|
|
||||||
vi.spyOn(useValidator, 'useValidator').mockImplementation(() => {
|
vi.spyOn(useValidator, 'useValidator').mockImplementation(() => {
|
||||||
return {
|
return {
|
||||||
validate: vi.fn(),
|
validate: vi.fn(),
|
||||||
|
@ -112,5 +82,4 @@ export function createWrapper(component, options) {
|
||||||
|
|
||||||
return { vm, wrapper };
|
return { vm, wrapper };
|
||||||
}
|
}
|
||||||
|
export { flushPromises };
|
||||||
export { axios, flushPromises };
|
|
||||||
|
|
|
@ -1 +1,27 @@
|
||||||
// This file will be run before each test file, don't delete or vitest will not work.
|
// This file will be run before each test file, don't delete or vitest will not work.
|
||||||
|
import { vi } from 'vitest';
|
||||||
|
|
||||||
|
vi.mock('axios');
|
||||||
|
vi.mock('vue-router', () => ({
|
||||||
|
useRouter: () => ({
|
||||||
|
push: vi.fn(),
|
||||||
|
replace: vi.fn(),
|
||||||
|
currentRoute: {
|
||||||
|
value: {
|
||||||
|
params: {
|
||||||
|
id: 1,
|
||||||
|
},
|
||||||
|
meta: { moduleName: 'mockName' },
|
||||||
|
matched: [{ path: 'mockName/list' }],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
useRoute: () => ({
|
||||||
|
matched: [],
|
||||||
|
query: {},
|
||||||
|
params: {},
|
||||||
|
meta: { moduleName: 'mockName' },
|
||||||
|
path: 'mockSection/list',
|
||||||
|
}),
|
||||||
|
onBeforeRouteLeave: () => {},
|
||||||
|
}));
|
||||||
|
|
Loading…
Reference in New Issue