Skip to content

Commit

Permalink
fix(create-local-vue): fix max range stack size (fix #1768) (#1786)
Browse files Browse the repository at this point in the history
* test(create-local-vue): add a failing test

* fix(create-local-vue): avoid Vue instance pollution
  • Loading branch information
antoinerey authored Feb 11, 2021
1 parent fd43588 commit 30e5bc3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/shared/create-local-vue.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function _createLocalVue(
instance.config = cloneDeep(Vue.config)

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

// option merge strategies need to be exposed by reference
// so that merge strats registered by plugins can work properly
Expand Down
23 changes: 23 additions & 0 deletions test/specs/create-local-vue.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,27 @@ describeWithShallowAndMount('createLocalVue', mountingMethod => {
}
}
)

// This test is related to the issue 1768.
// See: https://github.com/vuejs/vue-test-utils/issues/1768
itSkipIf(
process.env.TEST_ENV === 'browser' || vueVersion < 2.6,
'Does not exceed maximum call stack size when no custom error handler is defined',
async () => {
const { error } = global.console
const spy = jest.spyOn(global.console, 'error')
const localVue = createLocalVue()

try {
mountingMethod(ComponentWithSyncError, { localVue })
} catch {
const expected = expect.stringMatching(
/Maximum call stack size exceeded/
)

global.console.error = error
expect(spy).not.toHaveBeenCalledWith(expected)
}
}
)
})

0 comments on commit 30e5bc3

Please sign in to comment.