@@ -151,6 +151,66 @@ describeWithShallowAndMount('createLocalVue', mountingMethod => {
151151 }
152152 )
153153
154+ itSkipIf (
155+ vueVersion < 2.6 ,
156+ 'Exception suppresed in `errorHandler` is not logged to console.error' ,
157+ async ( ) => {
158+ const component = Vue . component ( 'TestComponent' , {
159+ template : '<button id="btn" @click="clickHandler">Click me</button>' ,
160+ methods : {
161+ clickHandler ( ) {
162+ throw new Error ( 'Should not be logged' )
163+ }
164+ }
165+ } )
166+ const errorHandler = jest . fn ( )
167+ const localVue = createLocalVue ( {
168+ errorHandler
169+ } )
170+ const wrapper = mountingMethod ( component , { localVue } )
171+ await wrapper . vm . $nextTick ( )
172+
173+ const { error } = global . console
174+ const spy = jest . spyOn ( global . console , 'error' )
175+ await wrapper . trigger ( 'click' )
176+ global . console . error = error
177+ expect ( spy ) . not . toHaveBeenCalled ( )
178+ }
179+ )
180+
181+ itSkipIf (
182+ vueVersion < 2.6 ,
183+ 'Exception raised in `errorHandler` bubbles up' ,
184+ async ( ) => {
185+ const component = Vue . component ( 'TestComponent' , {
186+ template : '<button id="btn" @click="clickHandler">Click me</button>' ,
187+ methods : {
188+ clickHandler ( ) {
189+ throw new Error ( )
190+ }
191+ }
192+ } )
193+ const errorHandler = ( err , vm , info ) => {
194+ if ( err ) {
195+ throw new Error ( 'An error that should log' )
196+ }
197+ }
198+ const localVue = createLocalVue ( {
199+ errorHandler
200+ } )
201+ const wrapper = mountingMethod ( component , { localVue } )
202+ await wrapper . vm . $nextTick ( )
203+
204+ const { error } = global . console
205+ const spy = jest . spyOn ( global . console , 'error' )
206+ await wrapper . trigger ( 'click' )
207+ global . console . error = error
208+ expect ( spy ) . toHaveBeenCalledWith (
209+ '[Vue warn]: Error in config.errorHandler: "Error: An error that should log"'
210+ )
211+ }
212+ )
213+
154214 itSkipIf (
155215 process . env . TEST_ENV === 'browser' || vueVersion < 2.6 ,
156216 'Calls `errorHandler` when an error is thrown asynchronously' ,
0 commit comments