feat: update_vitest_version to 2.0.0
gitea/salix-front/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Javier Segarra 2024-12-23 12:23:53 +01:00
parent 8b3b74a972
commit 099c613ccc
6 changed files with 187 additions and 551 deletions

View File

@ -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",

File diff suppressed because it is too large Load Diff

View File

@ -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,
},
})
);

View File

@ -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;

View File

@ -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 };

View File

@ -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: () => {},
}));