diff --git a/packages/server-test-utils/scripts/build.js b/packages/server-test-utils/scripts/build.js index 2c0a76d81..306de35f4 100644 --- a/packages/server-test-utils/scripts/build.js +++ b/packages/server-test-utils/scripts/build.js @@ -57,5 +57,6 @@ rollupOptions.forEach(options => { .then(() => success(`${options.format} build successful`)) .catch((err) => { error(err) + process.exit(1) }) }) diff --git a/packages/test-utils/scripts/build.js b/packages/test-utils/scripts/build.js index 92a6e33b0..6198c6232 100644 --- a/packages/test-utils/scripts/build.js +++ b/packages/test-utils/scripts/build.js @@ -70,5 +70,6 @@ rollupOptions.forEach(options => { .then(() => success(`${options.format} build successful`)) .catch((err) => { error(err) + process.exit(1) }) }) diff --git a/packages/test-utils/src/order-watchers.js b/packages/test-utils/src/order-watchers.js index 371b11014..3563aedc8 100644 --- a/packages/test-utils/src/order-watchers.js +++ b/packages/test-utils/src/order-watchers.js @@ -22,7 +22,7 @@ function orderVmWatchers (vm) { }) } - orderDeps(vm._watcher) + vm._watcher && orderDeps(vm._watcher) vm.$children.forEach(orderVmWatchers) } diff --git a/test/resources/utils.js b/test/resources/utils.js index 58e062eb1..548bf2fd9 100644 --- a/test/resources/utils.js +++ b/test/resources/utils.js @@ -16,21 +16,15 @@ export const isRunningPhantomJS = navigator.userAgent.includes && navigator.userAgent.match(/PhantomJS/i) -export function injectSupported () { - return vueVersion > 2.2 -} +export const injectSupported = vueVersion > 2.2 -export function attrsSupported () { - return vueVersion > 2.2 -} +export const attrsSupported = vueVersion > 2.2 -export function listenersSupported () { - return vueVersion > 2.3 -} +export const listenersSupported = vueVersion > 2.3 -export function functionalSFCsSupported () { - return vueVersion >= 2.5 -} +export const functionalSFCsSupported = vueVersion > 2.4 + +export const scopedSlotsSupported = vueVersion > 2 const shallowAndMount = process.env.TEST_ENV === 'node' ? [] diff --git a/test/specs/mount.spec.js b/test/specs/mount.spec.js index 2ae15c4cb..24f40730d 100644 --- a/test/specs/mount.spec.js +++ b/test/specs/mount.spec.js @@ -145,7 +145,7 @@ describeIf(process.env.TEST_ENV !== 'node', 'prop': 'val' } }) - if (injectSupported()) { + if (injectSupported) { // provide is added by Vue, it's a function in Vue > 2.3 if (vueVersion > 2.3) { expect(typeof wrapper.vm.$options.provide).to.equal('function') diff --git a/test/specs/mounting-options/attrs.spec.js b/test/specs/mounting-options/attrs.spec.js index b9982c3ff..ba3a0d8da 100644 --- a/test/specs/mounting-options/attrs.spec.js +++ b/test/specs/mounting-options/attrs.spec.js @@ -10,7 +10,7 @@ describeWithMountingMethods('options.attrs', (mountingMethod) => { itSkipIf( mountingMethod.name === 'renderToString' || isRunningPhantomJS, 'handles inherit attrs', () => { - if (!attrsSupported()) return + if (!attrsSupported) return const wrapper = mountingMethod(compileToFunctions('<p :id="anAttr" />'), { attrs: { anAttr: 'an attribute' diff --git a/test/specs/mounting-options/listeners.spec.js b/test/specs/mounting-options/listeners.spec.js index 0f3364851..086127c7d 100644 --- a/test/specs/mounting-options/listeners.spec.js +++ b/test/specs/mounting-options/listeners.spec.js @@ -9,7 +9,7 @@ import { describeWithShallowAndMount('options.listeners', (mountingMethod) => { itSkipIf(isRunningPhantomJS, 'handles inherit listeners', () => { - if (!listenersSupported()) return + if (!listenersSupported) return const aListener = () => {} const wrapper = mountingMethod(compileToFunctions('<p :id="aListener" />'), { listeners: { diff --git a/test/specs/mounting-options/provide.spec.js b/test/specs/mounting-options/provide.spec.js index a46432047..29fb8b785 100644 --- a/test/specs/mounting-options/provide.spec.js +++ b/test/specs/mounting-options/provide.spec.js @@ -19,9 +19,9 @@ describeWithMountingMethods('options.provide', (mountingMethod) => { config.provide = configProvideSave }) - itDoNotRunIf(!injectSupported(), + itDoNotRunIf(!injectSupported, 'provides objects which is injected by mounted component', () => { - if (!injectSupported()) return + if (!injectSupported) return const wrapper = mountingMethod(ComponentWithInject, { provide: { fromMount: 'objectValue' } @@ -32,7 +32,7 @@ describeWithMountingMethods('options.provide', (mountingMethod) => { expect(HTML).to.contain('objectValue') }) - itDoNotRunIf(!injectSupported(), + itDoNotRunIf(!injectSupported, 'provides function which is injected by mounted component', () => { const wrapper = mountingMethod(ComponentWithInject, { provide () { @@ -47,9 +47,9 @@ describeWithMountingMethods('options.provide', (mountingMethod) => { expect(HTML).to.contain('functionValue') }) - itDoNotRunIf(!injectSupported() || mountingMethod.name === 'renderToString', + itDoNotRunIf(!injectSupported || mountingMethod.name === 'renderToString', 'supports beforeCreate in component', () => { - if (!injectSupported()) return + if (!injectSupported) return const wrapper = mountingMethod(ComponentWithInject, { provide: { fromMount: '_' } @@ -60,7 +60,7 @@ describeWithMountingMethods('options.provide', (mountingMethod) => { itSkipIf(mountingMethod.name === 'renderToString', 'injects the provide from the config', () => { - if (!injectSupported()) { + if (!injectSupported) { return } config.provide['fromMount'] = 'globalConfig' @@ -73,7 +73,7 @@ describeWithMountingMethods('options.provide', (mountingMethod) => { expect(HTML).to.contain('globalConfig') }) - itDoNotRunIf(!injectSupported(), 'prioritize mounting options over config', () => { + itDoNotRunIf(!injectSupported, 'prioritize mounting options over config', () => { config.provide['fromMount'] = 'globalConfig' const wrapper = mountingMethod(ComponentWithInject, { diff --git a/test/specs/wrapper/contains.spec.js b/test/specs/wrapper/contains.spec.js index 9d292e1be..e0ac6f747 100644 --- a/test/specs/wrapper/contains.spec.js +++ b/test/specs/wrapper/contains.spec.js @@ -24,7 +24,7 @@ describeWithShallowAndMount('contains', (mountingMethod) => { }) it('returns true if wrapper contains functional Vue component', () => { - if (!functionalSFCsSupported()) { + if (!functionalSFCsSupported) { return false } const TestComponent = { diff --git a/test/specs/wrapper/find.spec.js b/test/specs/wrapper/find.spec.js index c4685d58e..d26cd6710 100644 --- a/test/specs/wrapper/find.spec.js +++ b/test/specs/wrapper/find.spec.js @@ -132,7 +132,7 @@ describeWithShallowAndMount('find', (mountingMethod) => { }) it('returns Wrapper of Vue Component matching functional component', () => { - if (!functionalSFCsSupported()) { + if (!functionalSFCsSupported) { return } const TestComponent = { diff --git a/test/specs/wrapper/findAll.spec.js b/test/specs/wrapper/findAll.spec.js index 78584cdc4..b207d6187 100644 --- a/test/specs/wrapper/findAll.spec.js +++ b/test/specs/wrapper/findAll.spec.js @@ -218,7 +218,7 @@ describeWithShallowAndMount('findAll', (mountingMethod) => { }) it('returns Wrapper of Vue Component matching functional component', () => { - if (!functionalSFCsSupported()) { + if (!functionalSFCsSupported) { return } const TestComponent = { diff --git a/test/specs/wrapper/is.spec.js b/test/specs/wrapper/is.spec.js index 95ae99b36..25a32ee3d 100644 --- a/test/specs/wrapper/is.spec.js +++ b/test/specs/wrapper/is.spec.js @@ -62,7 +62,7 @@ describeWithShallowAndMount('is', (mountingMethod) => { }) it('returns true if root node matches functional Component', () => { - if (!functionalSFCsSupported()) { + if (!functionalSFCsSupported) { return } const wrapper = mountingMethod(FunctionalComponent) diff --git a/test/specs/wrapper/props.spec.js b/test/specs/wrapper/props.spec.js index 53a399fc0..bce89ee19 100644 --- a/test/specs/wrapper/props.spec.js +++ b/test/specs/wrapper/props.spec.js @@ -36,7 +36,7 @@ describeWithShallowAndMount('props', (mountingMethod) => { expect(wrapper.props()).to.eql({ prop1: {}, prop2: 'val2' }) // fail }) - itSkipIf(!functionalSFCsSupported(), + itSkipIf(!functionalSFCsSupported, 'works correctly a functional component', () => { const FunctionalComponent = { render: h => h('div'), diff --git a/test/specs/wrapper/trigger.spec.js b/test/specs/wrapper/trigger.spec.js index df112b146..4d6622730 100644 --- a/test/specs/wrapper/trigger.spec.js +++ b/test/specs/wrapper/trigger.spec.js @@ -1,5 +1,11 @@ import ComponentWithEvents from '~resources/components/component-with-events.vue' -import { describeWithShallowAndMount } from '~resources/utils' +import ComponentWithScopedSlots from '~resources/components/component-with-scoped-slots.vue' +import { + describeWithShallowAndMount, + itDoNotRunIf, + scopedSlotsSupported +} from '~resources/utils' +import Vue from 'vue' describeWithShallowAndMount('trigger', (mountingMethod) => { let info @@ -116,6 +122,25 @@ describeWithShallowAndMount('trigger', (mountingMethod) => { wrapper.trigger('keydown') }) + itDoNotRunIf( + !scopedSlotsSupported, + 'handles instances without update watchers', () => { + const vm = new Vue() + const item = () => vm.$createElement('button') + const TestComponent = { + render (h) { + return h(ComponentWithScopedSlots, { + scopedSlots: { + noProps: item + } + }) + } + } + const wrapper = mountingMethod(TestComponent) + + wrapper.findAll('button').trigger('click') + }) + it('throws error if options contains a target value', () => { const wrapper = mountingMethod({ render: (h) => h('div') }) const div = wrapper.find('div')