Log error message to console, test is not working

This commit is contained in:
Moriz Wahl 2021-12-20 15:05:49 +01:00
parent 905e280463
commit e61d5a0bdb
2 changed files with 29 additions and 1 deletions

View File

@ -110,6 +110,9 @@ try {
mutations, mutations,
actions, actions,
}) })
} catch (error) {} } catch (error) {
// eslint-disable-next-line no-console
console.log(error)
}
export { store } export { store }

View File

@ -1,4 +1,8 @@
import { mutations, actions } from './store' import { mutations, actions } from './store'
import Vuex from 'vuex'
import Vue from 'vue'
jest.mock('vuex')
const { const {
language, language,
@ -298,4 +302,25 @@ describe('Vuex store', () => {
}) })
}) })
}) })
describe('creation of store fails', () => {
const consoleErrorMock = jest.fn()
const warnHandler = Vue.config.warnHandler
beforeEach(() => {
Vue.config.warnHandler = (w) => {}
// eslint-disable-next-line no-console
console.error = consoleErrorMock
Vuex.Store = () => {
throw new Error('no-cookies-allowed')
}
})
afterEach(() => {
Vue.config.warnHandler = warnHandler
})
it.skip('logs an error message', () => {
expect(consoleErrorMock).toBeCalledWith('no-cookies-allowed')
})
})
}) })