Fail for logged errors and vue warnings
Currently, there are cases where code evaluated in a jasmine test can produce a critical error, but still pass.
I encountered this with this MR: https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1983
I noticed that, without the fix in that MR, the related specs (https://gitlab.com/gitlab-org/gitlab-ee/blob/ee04c9dbc7885db441f77eed274ed9174621f0ec/spec/javascripts/environments/environment_spec.js#L154-163) were console.error
ing a TypeError
and a couple related Vue warnings. The interesting thing is that the TypeError
must not have been uncaught as the test still passes.
If you apply the fix, the TypeError
is no longer sent to console and the vue warnings disappear and the test still passes (as expected).
Seeing as this is new behaviour to me, I assume this is because of something Vue is doing. Seeing as this should be occuring in the render, maybe its catching these errors and not bubbling them up? Maybe its something we're doing strange. ¯\_(ツ)_/¯
After reading https://github.com/vuejs/vue/issues/4370#issuecomment-264480048 I'm thinking we should globally spy on console.error
to hoover up these critical failures.
Is there a better way? This works fine for vue warnings because we can test for [Vue warn]
or whatever it prepends to its warnings. But I'm not sure about failing for everything that gets console.error
ed.
/cc @filipa @mikegreiling