Skip to content

Commit 30e5bc3

Browse files
authored
fix(create-local-vue): fix max range stack size (fix #1768) (#1786)
* test(create-local-vue): add a failing test * fix(create-local-vue): avoid Vue instance pollution
1 parent fd43588 commit 30e5bc3

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

packages/shared/create-local-vue.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function _createLocalVue(
3636
instance.config = cloneDeep(Vue.config)
3737

3838
// if a user defined errorHandler is defined by a localVue instance via createLocalVue, register it
39-
instance.config.errorHandler = config.errorHandler || Vue.config.errorHandler
39+
instance.config.errorHandler = config.errorHandler
4040

4141
// option merge strategies need to be exposed by reference
4242
// so that merge strats registered by plugins can work properly

test/specs/create-local-vue.spec.js

+23
Original file line numberDiff line numberDiff line change
@@ -231,4 +231,27 @@ describeWithShallowAndMount('createLocalVue', mountingMethod => {
231231
}
232232
}
233233
)
234+
235+
// This test is related to the issue 1768.
236+
// See: https://github.com/vuejs/vue-test-utils/issues/1768
237+
itSkipIf(
238+
process.env.TEST_ENV === 'browser' || vueVersion < 2.6,
239+
'Does not exceed maximum call stack size when no custom error handler is defined',
240+
async () => {
241+
const { error } = global.console
242+
const spy = jest.spyOn(global.console, 'error')
243+
const localVue = createLocalVue()
244+
245+
try {
246+
mountingMethod(ComponentWithSyncError, { localVue })
247+
} catch {
248+
const expected = expect.stringMatching(
249+
/Maximum call stack size exceeded/
250+
)
251+
252+
global.console.error = error
253+
expect(spy).not.toHaveBeenCalledWith(expected)
254+
}
255+
}
256+
)
234257
})

0 commit comments

Comments
 (0)