Unit tests
This commit is contained in:
parent
3683502f30
commit
1af0a3db31
|
@ -29,7 +29,7 @@ module.exports = {
|
||||||
// statements: 50
|
// statements: 50
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
testMatch: ['<rootDir>/test/jest/__tests__/**/*.(spec|test).js', '<rootDir>/src/**/*.jest.(spec|test).js'],
|
testMatch: ['<rootDir>/src/**/__tests__/*.(spec|test).+(ts|js)?(x)'],
|
||||||
moduleFileExtensions: ['vue', 'js', 'jsx', 'json'],
|
moduleFileExtensions: ['vue', 'js', 'jsx', 'json'],
|
||||||
moduleNameMapper: {
|
moduleNameMapper: {
|
||||||
'^quasar$': 'quasar/dist/quasar.esm.prod.js',
|
'^quasar$': 'quasar/dist/quasar.esm.prod.js',
|
||||||
|
|
|
@ -6,11 +6,11 @@ import UserPanel from '../UserPanel.vue';
|
||||||
|
|
||||||
// Specify here Quasar config you'll need to test your component
|
// Specify here Quasar config you'll need to test your component
|
||||||
installQuasarPlugin();
|
installQuasarPlugin();
|
||||||
const routerPushMock = jest.fn();
|
const mockPush = jest.fn();
|
||||||
|
|
||||||
jest.mock('vue-router', () => ({
|
jest.mock('vue-router', () => ({
|
||||||
useRouter: () => ({
|
useRouter: () => ({
|
||||||
push: routerPushMock,
|
push: mockPush,
|
||||||
}),
|
}),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
@ -12,14 +12,22 @@ installQuasarPlugin({
|
||||||
Notify
|
Notify
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const routerPushMock = jest.fn();
|
|
||||||
|
// https://stackoverflow.com/questions/68763693/vue-routers-injection-fails-during-a-jest-unit-test
|
||||||
|
const mockPush = jest.fn();
|
||||||
|
const mockT = jest.fn();
|
||||||
|
|
||||||
jest.mock('vue-router', () => ({
|
jest.mock('vue-router', () => ({
|
||||||
useRouter: () => ({
|
useRouter: () => ({
|
||||||
push: routerPushMock,
|
push: mockPush,
|
||||||
}),
|
}),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
jest.mock('vue-i18n', () => ({
|
||||||
|
useI18n: () => ({
|
||||||
|
t: mockT
|
||||||
|
}),
|
||||||
|
}));
|
||||||
|
|
||||||
describe('Login', () => {
|
describe('Login', () => {
|
||||||
it('should successfully set the token into session', async () => {
|
it('should successfully set the token into session', async () => {
|
||||||
|
|
Loading…
Reference in New Issue