WIP: feat: update_vitest_version to 2.0.0 #1127
|
@ -51,7 +51,7 @@
|
|||
"husky": "^8.0.0",
|
||||
"postcss": "^8.4.23",
|
||||
"prettier": "^2.8.8",
|
||||
"vitest": "^0.31.1"
|
||||
"vitest": "^2.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"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 { 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 { 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 { vi, beforeEach, afterEach, beforeAll, describe, expect, it } from 'vitest';
|
||||
import { Notify } from 'quasar';
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
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';
|
||||
|
||||
describe('VnLog', () => {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
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';
|
||||
|
||||
describe('VnPaginate', () => {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
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';
|
||||
|
||||
describe('parsePhone filter', () => {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
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';
|
||||
|
||||
describe('VnSms', () => {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
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 { useSession } from 'src/composables/useSession';
|
||||
const session = useSession();
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
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';
|
||||
|
||||
describe('useAcl', () => {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
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 { useRouter } from 'vue-router';
|
||||
import * as vueRouter from 'vue-router';
|
||||
|
@ -25,8 +26,8 @@ describe('useArrayData', () => {
|
|||
arrayData.fetch({});
|
||||
|
||||
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({
|
||||
filter,
|
||||
supplierFk: 2,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
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';
|
||||
const role = useRole();
|
||||
|
||||
|
@ -31,10 +32,9 @@ describe('useRole', () => {
|
|||
lang: 'en',
|
||||
};
|
||||
const expectedRoles = ['salesPerson', 'admin'];
|
||||
vi.spyOn(axios, 'get')
|
||||
.mockResolvedValueOnce({
|
||||
vi.spyOn(axios, 'get').mockResolvedValueOnce({
|
||||
data: { roles: rolesData, user: fetchedUser },
|
||||
})
|
||||
});
|
||||
|
||||
vi.spyOn(role.state, 'setUser');
|
||||
vi.spyOn(role.state, 'setRoles');
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
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 { useState } from 'composables/useState';
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
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';
|
||||
const tokenConfig = useTokenConfig();
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
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';
|
||||
|
||||
describe('ClaimDescriptorMenu', () => {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
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';
|
||||
|
||||
describe('ClaimLines', () => {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
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';
|
||||
|
||||
describe('ClaimLinesImport', () => {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
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';
|
||||
|
||||
describe('ClaimPhoto', () => {
|
||||
let vm;
|
||||
|
||||
|
@ -61,7 +61,7 @@ describe('ClaimPhoto', () => {
|
|||
title: 'This file will be deleted',
|
||||
icon: 'delete',
|
||||
data: { index: 1 },
|
||||
promise: vm.deleteDms
|
||||
promise: vm.deleteDms,
|
||||
},
|
||||
})
|
||||
);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
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';
|
||||
|
||||
describe('CustomerPayments', () => {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
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 axios from 'axios';
|
||||
|
||||
describe('Login', () => {
|
||||
let vm;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
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';
|
||||
|
||||
// #4836 - Investigate how to test q-drawer outside
|
||||
|
@ -21,7 +22,11 @@ describe('TicketBoxing', () => {
|
|||
min: 1,
|
||||
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(vm.quasar, 'notify');
|
||||
|
@ -44,7 +49,9 @@ describe('TicketBoxing', () => {
|
|||
|
||||
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 { 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 { Notify } from 'quasar';
|
||||
import { nextTick } from 'vue';
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
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';
|
||||
|
||||
describe('WagonCreate', () => {
|
||||
|
|
|
@ -4,7 +4,6 @@ import { createTestingPinia } from '@pinia/testing';
|
|||
import { vi } from 'vitest';
|
||||
import { i18n } from 'src/boot/i18n';
|
||||
import { Notify, Dialog } from 'quasar';
|
||||
import axios from 'axios';
|
||||
import * as useValidator from 'src/composables/useValidator';
|
||||
|
||||
installQuasarPlugin({
|
||||
|
@ -14,35 +13,6 @@ installQuasarPlugin({
|
|||
},
|
||||
});
|
||||
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(() => {
|
||||
return {
|
||||
validate: vi.fn(),
|
||||
|
@ -112,5 +82,4 @@ export function createWrapper(component, options) {
|
|||
|
||||
return { vm, wrapper };
|
||||
}
|
||||
|
||||
export { axios, flushPromises };
|
||||
export { flushPromises };
|
||||
|
|
|
@ -1 +1,27 @@
|
|||
// 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