diff --git a/package.json b/package.json index 09c1abc33..5f5a71907 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "babel-preset-flow-vue": "^1.0.0", "babel-preset-stage-2": "^6.24.1", "chai": "^4.0.0", + "conditional-specs": "^1.0.1", "cross-env": "^5.0.0", "css-loader": "^0.28.4", "eslint": "^4.18.1", diff --git a/test/resources/utils.js b/test/resources/utils.js index 9d28cd6a0..1ddc1bac0 100644 --- a/test/resources/utils.js +++ b/test/resources/utils.js @@ -1,4 +1,4 @@ -/* global describe, it*/ +/* global describe */ import Vue from 'vue' import { shallowMount, mount } from '~vue/test-utils' @@ -70,45 +70,3 @@ describeWithMountingMethods.only = function (spec, cb) { describe.only(`${spec} with ${method.name}`, () => cb(method)) }) } - -export function itSkipIf (predicate, spec, cb) { - if (predicate) { - it.skip(spec, cb) - } else { - it(spec, cb) - } -} - -itSkipIf.only = (predicate, spec, cb) => { - if (predicate) { - it.skip(spec, cb) - } else { - it.only(spec, cb) - } -} - -export function itDoNotRunIf (predicate, spec, cb) { - if (predicate) { - () => {} - } else { - it(spec, cb) - } -} - -itDoNotRunIf.only = (predicate, spec, cb) => { - if (!predicate) { - it.only(spec, cb) - } -} - -export function describeIf (predicate, spec, cb) { - if (predicate) { - describe(spec, cb) - } -} - -describeIf.only = (predicate, spec, cb) => { - if (predicate) { - describe(spec, cb) - } -} diff --git a/test/specs/config.spec.js b/test/specs/config.spec.js index 2fd5717ab..94820285e 100644 --- a/test/specs/config.spec.js +++ b/test/specs/config.spec.js @@ -1,9 +1,11 @@ import { describeWithShallowAndMount, - itDoNotRunIf, - itSkipIf, vueVersion } from '~resources/utils' +import { + itDoNotRunIf, + itSkipIf +} from 'conditional-specs' import { config, TransitionStub, TransitionGroupStub, createLocalVue } from '~vue/test-utils' import Vue from 'vue' diff --git a/test/specs/create-local-vue.spec.js b/test/specs/create-local-vue.spec.js index 0be21cb4c..7e8501944 100644 --- a/test/specs/create-local-vue.spec.js +++ b/test/specs/create-local-vue.spec.js @@ -6,10 +6,8 @@ import { createLocalVue } from '~vue/test-utils' 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 { - describeWithShallowAndMount, - itDoNotRunIf -} from '~resources/utils' +import { describeWithShallowAndMount } from '~resources/utils' +import { itDoNotRunIf } from 'conditional-specs' describeWithShallowAndMount('createLocalVue', (mountingMethod) => { it('installs Vuex without polluting global Vue', () => { diff --git a/test/specs/mount.spec.js b/test/specs/mount.spec.js index 9c38bf39d..67997efe9 100644 --- a/test/specs/mount.spec.js +++ b/test/specs/mount.spec.js @@ -4,9 +4,10 @@ import { mount, createLocalVue } from '~vue/test-utils' import Component from '~resources/components/component.vue' import ComponentWithProps from '~resources/components/component-with-props.vue' import ComponentWithMixin from '~resources/components/component-with-mixin.vue' -import { injectSupported, vueVersion, describeIf } from '~resources/utils' +import { injectSupported, vueVersion } from '~resources/utils' +import { describeRunIf } from 'conditional-specs' -describeIf(process.env.TEST_ENV !== 'node', +describeRunIf(process.env.TEST_ENV !== 'node', 'mount', () => { let consoleError diff --git a/test/specs/mounting-options/attrs.spec.js b/test/specs/mounting-options/attrs.spec.js index ba3a0d8da..7ae44fd36 100644 --- a/test/specs/mounting-options/attrs.spec.js +++ b/test/specs/mounting-options/attrs.spec.js @@ -2,9 +2,11 @@ import { compileToFunctions } from 'vue-template-compiler' import { attrsSupported } from '~resources/utils' import { describeWithMountingMethods, - itSkipIf, isRunningPhantomJS } from '~resources/utils' +import { + itSkipIf +} from 'conditional-specs' describeWithMountingMethods('options.attrs', (mountingMethod) => { itSkipIf( diff --git a/test/specs/mounting-options/listeners.spec.js b/test/specs/mounting-options/listeners.spec.js index 086127c7d..8673141f1 100644 --- a/test/specs/mounting-options/listeners.spec.js +++ b/test/specs/mounting-options/listeners.spec.js @@ -2,9 +2,11 @@ import { compileToFunctions } from 'vue-template-compiler' import { listenersSupported } from '~resources/utils' import { describeWithShallowAndMount, - itSkipIf, isRunningPhantomJS } from '~resources/utils' +import { + itSkipIf +} from 'conditional-specs' describeWithShallowAndMount('options.listeners', (mountingMethod) => { itSkipIf(isRunningPhantomJS, diff --git a/test/specs/mounting-options/localVue.spec.js b/test/specs/mounting-options/localVue.spec.js index 8eeed35d9..1410251f7 100644 --- a/test/specs/mounting-options/localVue.spec.js +++ b/test/specs/mounting-options/localVue.spec.js @@ -1,11 +1,11 @@ import Vue from 'vue' import { describeWithMountingMethods, - itSkipIf, isRunningPhantomJS, vueVersion } from '~resources/utils' import { createLocalVue } from '~vue/test-utils' +import { itSkipIf } from 'conditional-specs' import Vuex from 'vuex' describeWithMountingMethods('options.localVue', (mountingMethod) => { diff --git a/test/specs/mounting-options/mocks.spec.js b/test/specs/mounting-options/mocks.spec.js index 712f74df1..451e9de4e 100644 --- a/test/specs/mounting-options/mocks.spec.js +++ b/test/specs/mounting-options/mocks.spec.js @@ -1,10 +1,8 @@ import { createLocalVue, config } from '~vue/test-utils' import Component from '~resources/components/component.vue' import ComponentWithVuex from '~resources/components/component-with-vuex.vue' -import { - describeWithMountingMethods, - itDoNotRunIf -} from '~resources/utils' +import { describeWithMountingMethods } from '~resources/utils' +import { itDoNotRunIf } from 'conditional-specs' describeWithMountingMethods('options.mocks', (mountingMethod) => { let configMocksSave diff --git a/test/specs/mounting-options/provide.spec.js b/test/specs/mounting-options/provide.spec.js index 29fb8b785..9c9f61f96 100644 --- a/test/specs/mounting-options/provide.spec.js +++ b/test/specs/mounting-options/provide.spec.js @@ -1,11 +1,11 @@ import { config } from '~vue/test-utils' import ComponentWithInject from '~resources/components/component-with-inject.vue' import { injectSupported } from '~resources/utils' +import { describeWithMountingMethods } from '~resources/utils' import { - describeWithMountingMethods, itDoNotRunIf, itSkipIf -} from '~resources/utils' +} from 'conditional-specs' describeWithMountingMethods('options.provide', (mountingMethod) => { let configProvideSave diff --git a/test/specs/mounting-options/scopedSlots.spec.js b/test/specs/mounting-options/scopedSlots.spec.js index 846a1724e..e3347c39a 100644 --- a/test/specs/mounting-options/scopedSlots.spec.js +++ b/test/specs/mounting-options/scopedSlots.spec.js @@ -1,10 +1,10 @@ import { describeWithShallowAndMount, vueVersion, - itDoNotRunIf, isRunningPhantomJS } from '~resources/utils' import ComponentWithScopedSlots from '~resources/components/component-with-scoped-slots.vue' +import { itDoNotRunIf } from 'conditional-specs' describeWithShallowAndMount('scopedSlots', (mountingMethod) => { let _window diff --git a/test/specs/mounting-options/slots.spec.js b/test/specs/mounting-options/slots.spec.js index 5bdf898c4..ab6dab1bc 100644 --- a/test/specs/mounting-options/slots.spec.js +++ b/test/specs/mounting-options/slots.spec.js @@ -5,10 +5,12 @@ import ComponentAsAClass from '~resources/components/component-as-a-class.vue' import { describeWithMountingMethods, vueVersion, - itSkipIf, - itDoNotRunIf, isRunningPhantomJS } from '~resources/utils' +import { + itSkipIf, + itDoNotRunIf +} from 'conditional-specs' describeWithMountingMethods('options.slots', (mountingMethod) => { let _window diff --git a/test/specs/mounting-options/stubs.spec.js b/test/specs/mounting-options/stubs.spec.js index e41382bc0..bab14ccad 100644 --- a/test/specs/mounting-options/stubs.spec.js +++ b/test/specs/mounting-options/stubs.spec.js @@ -5,10 +5,8 @@ import ComponentAsAClass from '~resources/components/component-as-a-class.vue' import { createLocalVue, config } from '~vue/test-utils' import { config as serverConfig } from '~vue/server-test-utils' import Vue from 'vue' -import { - describeWithMountingMethods, - itDoNotRunIf -} from '~resources/utils' +import { describeWithMountingMethods } from '~resources/utils' +import { itDoNotRunIf } from 'conditional-specs' describeWithMountingMethods('options.stub', (mountingMethod) => { let info diff --git a/test/specs/renderToString.spec.js b/test/specs/renderToString.spec.js index 58c9f4aea..60e398933 100644 --- a/test/specs/renderToString.spec.js +++ b/test/specs/renderToString.spec.js @@ -1,9 +1,7 @@ import { renderToString } from '~vue/server-test-utils' import Component from '~resources/components/component.vue' -import { - isRunningJSDOM, - itDoNotRunIf -} from '~resources/utils' +import { isRunningJSDOM } from '~resources/utils' +import { itDoNotRunIf } from 'conditional-specs' describe.skip('renderToString', () => { itDoNotRunIf(isRunningJSDOM, diff --git a/test/specs/shallow-mount.spec.js b/test/specs/shallow-mount.spec.js index b9fa51d43..c1107e4dc 100644 --- a/test/specs/shallow-mount.spec.js +++ b/test/specs/shallow-mount.spec.js @@ -8,9 +8,10 @@ import ComponentWithLifecycleHooks from '~resources/components/component-with-li import ComponentWithoutName from '~resources/components/component-without-name.vue' import ComponentAsAClassWithChild from '~resources/components/component-as-a-class-with-child.vue' import RecursiveComponent from '~resources/components/recursive-component.vue' -import { vueVersion, describeIf } from '~resources/utils' +import { vueVersion } from '~resources/utils' +import { describeRunIf } from 'conditional-specs' -describeIf(process.env.TEST_ENV !== 'node', +describeRunIf(process.env.TEST_ENV !== 'node', 'shallowMount', () => { let info diff --git a/test/specs/shallow.spec.js b/test/specs/shallow.spec.js index b2fc0abce..63530d7c6 100644 --- a/test/specs/shallow.spec.js +++ b/test/specs/shallow.spec.js @@ -8,9 +8,10 @@ import ComponentWithLifecycleHooks from '~resources/components/component-with-li import ComponentWithoutName from '~resources/components/component-without-name.vue' import ComponentAsAClassWithChild from '~resources/components/component-as-a-class-with-child.vue' import RecursiveComponent from '~resources/components/recursive-component.vue' -import { vueVersion, describeIf } from '~resources/utils' +import { vueVersion } from '~resources/utils' +import { describeRunIf } from 'conditional-specs' -describeIf(process.env.TEST_ENV !== 'node', +describeRunIf(process.env.TEST_ENV !== 'node', 'shallowMount', () => { let info diff --git a/test/specs/wrapper/contains.spec.js b/test/specs/wrapper/contains.spec.js index e0ac6f747..1abb600b3 100644 --- a/test/specs/wrapper/contains.spec.js +++ b/test/specs/wrapper/contains.spec.js @@ -6,9 +6,9 @@ import ComponentAsAClass from '~resources/components/component-as-a-class.vue' import { functionalSFCsSupported, describeWithShallowAndMount, - isRunningPhantomJS, - itSkipIf + isRunningPhantomJS } from '~resources/utils' +import { itSkipIf } from 'conditional-specs' import ComponentWithoutName from '~resources/components/component-without-name.vue' describeWithShallowAndMount('contains', (mountingMethod) => { diff --git a/test/specs/wrapper/find.spec.js b/test/specs/wrapper/find.spec.js index d26cd6710..6064ed42a 100644 --- a/test/specs/wrapper/find.spec.js +++ b/test/specs/wrapper/find.spec.js @@ -11,10 +11,12 @@ import { functionalSFCsSupported, vueVersion, describeWithShallowAndMount, - isRunningPhantomJS, + isRunningPhantomJS +} from '~resources/utils' +import { itDoNotRunIf, itSkipIf -} from '~resources/utils' +} from 'conditional-specs' describeWithShallowAndMount('find', (mountingMethod) => { it('returns a Wrapper matching tag selector passed', () => { diff --git a/test/specs/wrapper/findAll.spec.js b/test/specs/wrapper/findAll.spec.js index b207d6187..88f2fe6a7 100644 --- a/test/specs/wrapper/findAll.spec.js +++ b/test/specs/wrapper/findAll.spec.js @@ -9,10 +9,12 @@ import ComponentAsAClass from '~resources/components/component-as-a-class.vue' import { functionalSFCsSupported, describeWithShallowAndMount, - itDoNotRunIf, - itSkipIf, isRunningPhantomJS } from '~resources/utils' +import { + itDoNotRunIf, + itSkipIf +} from 'conditional-specs' describeWithShallowAndMount('findAll', (mountingMethod) => { it('returns an WrapperArray of elements matching tag selector passed', () => { diff --git a/test/specs/wrapper/isEmpty.spec.js b/test/specs/wrapper/isEmpty.spec.js index 3216456b4..dca66d527 100644 --- a/test/specs/wrapper/isEmpty.spec.js +++ b/test/specs/wrapper/isEmpty.spec.js @@ -1,9 +1,9 @@ import { compileToFunctions } from 'vue-template-compiler' import { describeWithShallowAndMount, - itSkipIf, isRunningPhantomJS } from '~resources/utils' +import { itSkipIf } from 'conditional-specs' describeWithShallowAndMount('isEmpty', (mountingMethod) => { it('returns true if node is empty', () => { diff --git a/test/specs/wrapper/props.spec.js b/test/specs/wrapper/props.spec.js index bce89ee19..c325c76dc 100644 --- a/test/specs/wrapper/props.spec.js +++ b/test/specs/wrapper/props.spec.js @@ -2,9 +2,9 @@ import { compileToFunctions } from 'vue-template-compiler' import ComponentWithProps from '~resources/components/component-with-props.vue' import { describeWithShallowAndMount, - itSkipIf, functionalSFCsSupported } from '~resources/utils' +import { itSkipIf } from 'conditional-specs' describeWithShallowAndMount('props', (mountingMethod) => { it('returns true if wrapper has prop', () => { diff --git a/test/specs/wrapper/trigger.spec.js b/test/specs/wrapper/trigger.spec.js index 4d6622730..8b4b7bb5d 100644 --- a/test/specs/wrapper/trigger.spec.js +++ b/test/specs/wrapper/trigger.spec.js @@ -2,10 +2,10 @@ import ComponentWithEvents from '~resources/components/component-with-events.vue import ComponentWithScopedSlots from '~resources/components/component-with-scoped-slots.vue' import { describeWithShallowAndMount, - itDoNotRunIf, scopedSlotsSupported } from '~resources/utils' import Vue from 'vue' +import { itDoNotRunIf } from 'conditional-specs' describeWithShallowAndMount('trigger', (mountingMethod) => { let info diff --git a/yarn.lock b/yarn.lock index 4cd471715..ba62a4a3c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1753,6 +1753,10 @@ concat-stream@1.6.0, concat-stream@^1.4.10, concat-stream@^1.5.0, concat-stream@ readable-stream "^2.2.2" typedarray "^0.0.6" +conditional-specs@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/conditional-specs/-/conditional-specs-1.0.1.tgz#1137ca6f83e5de848853cf0cfac78fe858b40a9a" + config-chain@~1.1.10, config-chain@~1.1.11: version "1.1.11" resolved "https://registry.yarnpkg.com/config-chain/-/config-chain-1.1.11.tgz#aba09747dfbe4c3e70e766a6e41586e1859fc6f2"