Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

createLocalVue errorHandler Option #1670

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
48f1c14
refactor(createlocalvue): move createLocalVue to shared utils
AtofStryker Aug 26, 2020
808fe89
refactor(createlocalvue): rename createLocalVue to _createLocalVue
AtofStryker Aug 26, 2020
98103d6
improvement(components): add Sync and Async components for testing
AtofStryker Aug 27, 2020
fc3be6c
improvement(flow): add VueConfig to Flow
AtofStryker Aug 27, 2020
0dca580
improvement(index): export new createLocalVue as default in Index
AtofStryker Aug 27, 2020
094e7db
improvement(_createlocalvue): allow registration of user defined config
AtofStryker Aug 27, 2020
3db2482
improvement(find): add findAllParentInstances to the find API
AtofStryker Aug 27, 2020
f1005a9
improvement(mount): pass localVue into mounted createLocalVue
AtofStryker Aug 27, 2020
72f1fdb
improvement(error): call user defined errorHandler if defined
AtofStryker Aug 27, 2020
55647c4
improvement(createlocalvue): add tests to createLocalVue errorHandler
AtofStryker Aug 27, 2020
8bbc3d1
docs(createlocalvue): document public createLocalVue API
AtofStryker Aug 28, 2020
75d0afc
docs(createlocalvue): document the createLocalVue internal API
AtofStryker Aug 28, 2020
ba9f677
docs(createlocalvue): document the errorHandler option in createLocalVue
AtofStryker Aug 28, 2020
3272a85
fix(createlocalvue tests): wrap createLocalVue async test in try/finally
AtofStryker Aug 28, 2020
5783bb6
fix(createlocalvue): skip async component throws for vue < 2.6
AtofStryker Aug 28, 2020
5ed0f28
improvement(find and error): add additional type safety to find & error
AtofStryker Aug 28, 2020
d73e8d9
fix(createlocalvue): only run sync error tests for vue versions < 2.4
AtofStryker Aug 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
improvement(createlocalvue): add tests to createLocalVue errorHandler
add tests to createLocalVue errorHandler to test invocation on sync and async throws
  • Loading branch information
AtofStryker committed Aug 28, 2020
commit 55647c4cc6dd46ccf261199d9e3adb05ffd01767
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import Vue from 'vue'
import Vuex from 'vuex'
import VueRouter from 'vue-router'
import _createLocalVue from 'packages/shared/create-local-vue'
import { createLocalVue } from 'packages/test-utils/src'
import Component from '~resources/components/component.vue'
import ComponentWithVuex from '~resources/components/component-with-vuex.vue'
import ComponentWithRouter from '~resources/components/component-with-router.vue'
import ComponentWithSyncError from '~resources/components/component-with-sync-error.vue'
import ComponentWithAsyncError from '~resources/components/component-with-async-error.vue'
import { describeWithShallowAndMount } from '~resources/utils'
import { itDoNotRunIf } from 'conditional-specs'
import { itDoNotRunIf, itSkipIf } from 'conditional-specs'

describeWithShallowAndMount('createLocalVue', mountingMethod => {
it('installs Vuex without polluting global Vue', () => {
const localVue = _createLocalVue()
const localVue = createLocalVue()
localVue.use(Vuex)
const store = new Vuex.Store({
state: {
Expand All @@ -27,7 +29,7 @@ describeWithShallowAndMount('createLocalVue', mountingMethod => {
})

it('Vuex should work properly with local Vue', async () => {
const localVue = _createLocalVue()
const localVue = createLocalVue()
localVue.use(Vuex)
const store = new Vuex.Store({
state: {
Expand All @@ -53,7 +55,7 @@ describeWithShallowAndMount('createLocalVue', mountingMethod => {
})

it('installs Router without polluting global Vue', () => {
const localVue = _createLocalVue()
const localVue = createLocalVue()
localVue.use(VueRouter)
const routes = [{ path: '/foo', component: Component }]
const router = new VueRouter({
Expand All @@ -69,7 +71,7 @@ describeWithShallowAndMount('createLocalVue', mountingMethod => {
mountingMethod.name === 'shallowMount',
'Router should work properly with local Vue',
() => {
const localVue = _createLocalVue()
const localVue = createLocalVue()
localVue.use(VueRouter)
const routes = [
{
Expand Down Expand Up @@ -102,7 +104,7 @@ describeWithShallowAndMount('createLocalVue', mountingMethod => {
)

it('use can take additional arguments', () => {
const localVue = _createLocalVue()
const localVue = createLocalVue()
const pluginOptions = { foo: 'bar' }
const plugin = {
install: function(_Vue, options) {
Expand All @@ -124,12 +126,44 @@ describeWithShallowAndMount('createLocalVue', mountingMethod => {
}

Vue.use(Plugin)
const localVue = _createLocalVue()
const localVue = createLocalVue()
localVue.use(Plugin)

if (localVue._installedPlugins) {
expect(localVue._installedPlugins.indexOf(Plugin)).toEqual(0)
}
expect(installCount).toEqual(2)
})

it('Calls `errorHandler` when an error is thrown synchronously', () => {
const errorHandler = jest.fn()
const localVue = createLocalVue({
errorHandler
})
try {
mountingMethod(ComponentWithSyncError, { localVue })
} catch (e) {
// asserting arguments is a bit difficult due to multiple Vue version support. Please see https://vuejs.org/v2/api/#errorHandler for more details
expect(errorHandler).toHaveBeenCalledTimes(1)
}
})

itSkipIf(
process.env.TEST_ENV === 'browser',
'Calls `errorHandler` when an error is thrown asynchronously',
async () => {
const errorHandler = jest.fn()
const localVue = createLocalVue({
errorHandler
})

mountingMethod(ComponentWithAsyncError, { localVue })

await Vue.nextTick()
await setTimeout()

// asserting arguments is a bit difficult due to multiple Vue version support. Please see https://vuejs.org/v2/api/#errorHandler for more details
expect(errorHandler).toHaveBeenCalledTimes(1)
}
)
})
Morty Proxy This is a proxified and sanitized view of the page, visit original site.