mock console error only in the test for the error

This commit is contained in:
Moriz Wahl 2021-10-26 07:52:49 +02:00
parent a09b2200fc
commit f482eb7db6
2 changed files with 8 additions and 12 deletions

View File

@ -2,16 +2,10 @@ import { mount } from '@vue/test-utils'
import Transaction from './Transaction'
import Vue from 'vue'
// disable throwing Errors on warnings to catch the warning
Vue.config.warnHandler = (w) => {}
const localVue = global.localVue
const consoleErrorMock = jest.fn()
// eslint-disable-next-line no-console
console.error = consoleErrorMock
describe('Transaction', () => {
let wrapper
@ -43,6 +37,10 @@ describe('Transaction', () => {
describe('no valid GDT entry type', () => {
beforeEach(async () => {
// disable throwing Errors on warnings to catch the warning
Vue.config.warnHandler = (w) => {}
// eslint-disable-next-line no-console
console.error = consoleErrorMock
await wrapper.setProps({ gdtEntryType: 'NOT_VALID' })
})

View File

@ -4,16 +4,10 @@ import { GdtEntryType } from '../graphql/enums'
import Vue from 'vue'
// disable throwing Errors on warnings to catch the warning
Vue.config.warnHandler = (w) => {}
const localVue = global.localVue
const consoleErrorMock = jest.fn()
// eslint-disable-next-line no-console
console.error = consoleErrorMock
describe('TransactionCollapse', () => {
let wrapper
@ -28,6 +22,10 @@ describe('TransactionCollapse', () => {
describe('no valid GDT entry type', () => {
beforeEach(async () => {
// disable throwing Errors on warnings to catch the warning
Vue.config.warnHandler = (w) => {}
// eslint-disable-next-line no-console
console.error = consoleErrorMock
const propsData = {
amount: 100,
gdt: 110,