2024-05-29 09:11:48 +00:00
|
|
|
import { createTestingPinia } from '@pinia/testing';
|
|
|
|
import { mount } from 'cypress/vue';
|
|
|
|
import { i18n } from 'src/boot/i18n';
|
|
|
|
|
|
|
|
const pinia = createTestingPinia({ createSpy: () => {}, stubActions: false });
|
|
|
|
|
|
|
|
// // Run this code before each *test*.
|
|
|
|
// beforeEach(() => {
|
|
|
|
// // New Pinia
|
|
|
|
// pinia = createPinia();
|
|
|
|
// console.log(pinia);
|
|
|
|
// // Set current Pinia instance
|
|
|
|
// setActivePinia(pinia);
|
|
|
|
// });
|
|
|
|
|
|
|
|
function createWrapper(component, options) {
|
|
|
|
const defaultOptions = {
|
|
|
|
global: {
|
|
|
|
plugins: [i18n, pinia],
|
|
|
|
},
|
|
|
|
mocks: {
|
|
|
|
t: (tKey) => tKey,
|
|
|
|
$t: (tKey) => tKey,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const mountOptions = Object.assign({}, defaultOptions);
|
|
|
|
|
|
|
|
if (options instanceof Object) {
|
|
|
|
Object.assign(mountOptions, options);
|
|
|
|
|
|
|
|
if (options.global) {
|
|
|
|
mountOptions.global.plugins = defaultOptions.global.plugins;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const wrapper = mount(component, mountOptions);
|
|
|
|
const vm = wrapper.vm;
|
|
|
|
|
|
|
|
return wrapper;
|
|
|
|
}
|
|
|
|
// declare global {
|
|
|
|
// namespace Cypress {
|
|
|
|
// interface Chainable {
|
|
|
|
// createWrapper: typeof createWrapper;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
Cypress.Commands.add('createWrapper', createWrapper);
|
|
|
|
// Cypress.Commands.add('mount', mount);
|
2024-09-27 07:58:23 +00:00
|
|
|
import { shallowMount } from '@vue/test-utils';
|
|
|
|
import { Quasar } from 'quasar';
|
|
|
|
|
|
|
|
Cypress.Commands.add('vnMount', (component, options = {}) => {
|
|
|
|
const globalConfig = {
|
|
|
|
global: {
|
|
|
|
stubs: ['router-view', 'vue-i18n'],
|
|
|
|
plugins: [Quasar, i18n, pinia],
|
|
|
|
mocks: { t: (key) => key },
|
|
|
|
},
|
|
|
|
};
|
|
|
|
// options.global = options.global || {};
|
|
|
|
// options.global.stubs = options.global.stubs || {};
|
|
|
|
// options.global.stubs.transition = false;
|
|
|
|
// options.global.components = options.global.components || {};
|
|
|
|
// options.global.plugins = options.global.plugins || [];
|
|
|
|
|
|
|
|
// Use store passed in from options, or initialize a new one
|
|
|
|
// const { /* store = getStore(), */ ...mountOptions } = options;
|
|
|
|
|
|
|
|
// Add plugins here
|
|
|
|
// options.global.plugins.push({
|
|
|
|
// install(app) {
|
|
|
|
// app.use(i18n);
|
|
|
|
// },
|
|
|
|
// });
|
|
|
|
return shallowMount(component, { ...globalConfig, ...options });
|
|
|
|
});
|