From 9c98e30bb8ad38b6f5dc75cf8828db333646e62c Mon Sep 17 00:00:00 2001 From: roschaefer Date: Thu, 20 Feb 2020 14:20:57 +0100 Subject: [PATCH] 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/ --- webapp/components/PostTeaser/PostTeaser.spec.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/webapp/components/PostTeaser/PostTeaser.spec.js b/webapp/components/PostTeaser/PostTeaser.spec.js index e4b4dfe6f..cfa8fb5f7 100644 --- a/webapp/components/PostTeaser/PostTeaser.spec.js +++ b/webapp/components/PostTeaser/PostTeaser.spec.js @@ -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", } })