Fix console.errors

@mattwr18 @alina-beck there seems to be no switch or configuration to
let vue-test-utils or jest fail whenever there is a call to
`console.error`. The only way to test it for very specific tests is
this. I took it from here:

https://geedew.com/catching-prop-validation-in-vue-with-Jest/
This commit is contained in:
roschaefer 2020-02-20 14:20:57 +01:00
parent 701564c708
commit 9c98e30bb8

View File

@ -22,11 +22,13 @@ describe('PostTeaser', () => {
propsData = {
post: {
id: 'p23',
disabled: false,
shoutedCount: 0,
commentsCount: 0,
name: 'It is a post',
author: {
id: 'u1',
},
disabled: false,
},
}
stubs = {
@ -63,6 +65,13 @@ describe('PostTeaser', () => {
})
}
it('has no validation errors', () => {
const spy = jest.spyOn(global.console, 'error');
Wrapper()
expect(spy).not.toBeCalled()
spy.mockReset()
})
beforeEach(jest.useFakeTimers)
describe('test Post callbacks', () => {
@ -111,6 +120,7 @@ describe('PostTeaser', () => {
describe('given a post', () => {
beforeEach(() => {
propsData.post = {
...propsData.post,
title: "It's a title",
}
})