From 9c2e68f30a72834ee8336e98d2b5fdf870d50aa8 Mon Sep 17 00:00:00 2001 From: Lachlan Miller Date: Sat, 20 Jun 2020 18:08:13 +1000 Subject: [PATCH 01/46] refactor: use jest --- docs/api/wrapper-array/setChecked.md | 8 +- docs/api/wrapper-array/setValue.md | 8 +- docs/ja/api/wrapper-array/setChecked.md | 8 +- docs/ja/api/wrapper-array/setValue.md | 8 +- docs/ru/api/wrapper-array/setChecked.md | 8 +- docs/ru/api/wrapper-array/setValue.md | 8 +- docs/zh/api/wrapper-array/setChecked.md | 8 +- docs/zh/api/wrapper-array/setValue.md | 8 +- jest.config.js | 9 + package.json | 5 +- test/setup/mocha.setup.js | 14 - test/specs/components/RouterLink.spec.js | 18 +- test/specs/config.spec.js | 16 +- test/specs/create-dom-event.spec.js | 4 +- test/specs/create-local-vue.spec.js | 18 +- test/specs/create-wrapper.spec.js | 6 +- test/specs/error-wrapper.spec.js | 2 +- test/specs/mount.spec.js | 50 +- test/specs/mounting-options/attachTo.spec.js | 14 +- .../mounting-options/attachToDocument.spec.js | 2 +- test/specs/mounting-options/attrs.spec.js | 4 +- test/specs/mounting-options/listeners.spec.js | 2 +- test/specs/mounting-options/localVue.spec.js | 4 +- test/specs/mounting-options/mocks.spec.js | 4 +- test/specs/mounting-options/provide.spec.js | 14 +- .../mounting-options/scopedSlots.spec.js | 42 +- test/specs/mounting-options/slots.spec.js | 60 +- test/specs/mounting-options/stubs.spec.js | 14 +- test/specs/mounting-options/watch.spec.js | 2 +- test/specs/render.spec.js | 4 +- test/specs/shallow-mount.spec.js | 80 +- test/specs/vue-wrapper.spec.js | 2 +- test/specs/wrapper-array.spec.js | 52 +- test/specs/wrapper-array/contains.spec.js | 4 +- test/specs/wrapper-array/is.spec.js | 8 +- test/specs/wrapper-array/isEmpty.spec.js | 4 +- test/specs/wrapper-array/isVisible.spec.js | 6 +- .../specs/wrapper-array/isVueInstance.spec.js | 4 +- test/specs/wrapper-array/setChecked.spec.js | 12 +- test/specs/wrapper-array/setData.spec.js | 4 +- test/specs/wrapper-array/setProps.spec.js | 8 +- test/specs/wrapper-array/setValue.spec.js | 12 +- test/specs/wrapper-array/trigger.spec.js | 6 +- test/specs/wrapper.spec.js | 2 +- test/specs/wrapper/classes.spec.js | 2 +- test/specs/wrapper/contains.spec.js | 26 +- test/specs/wrapper/destroy.spec.js | 8 +- test/specs/wrapper/emitted.spec.js | 12 +- test/specs/wrapper/exists.spec.js | 6 +- test/specs/wrapper/find.spec.js | 60 +- test/specs/wrapper/findAll.spec.js | 78 +- test/specs/wrapper/html.spec.js | 8 +- test/specs/wrapper/is.spec.js | 26 +- test/specs/wrapper/isEmpty.spec.js | 16 +- test/specs/wrapper/isVisible.spec.js | 38 +- test/specs/wrapper/isVueInstance.spec.js | 4 +- test/specs/wrapper/name.spec.js | 6 +- test/specs/wrapper/props.spec.js | 2 +- test/specs/wrapper/setChecked.spec.js | 10 +- test/specs/wrapper/setData.spec.js | 44 +- test/specs/wrapper/setMethods.spec.js | 10 +- test/specs/wrapper/setProps.spec.js | 40 +- test/specs/wrapper/setSelected.spec.js | 2 +- test/specs/wrapper/setValue.spec.js | 6 +- test/specs/wrapper/text.spec.js | 4 +- test/specs/wrapper/trigger.spec.js | 20 +- yarn.lock | 1843 ++++++++++++++++- 67 files changed, 2299 insertions(+), 548 deletions(-) create mode 100644 jest.config.js diff --git a/docs/api/wrapper-array/setChecked.md b/docs/api/wrapper-array/setChecked.md index d3dc1ff6f..e59784c89 100644 --- a/docs/api/wrapper-array/setChecked.md +++ b/docs/api/wrapper-array/setChecked.md @@ -31,9 +31,9 @@ const wrapper = mount({ }) const wrapperArray = wrapper.findAll('.foo') -expect(wrapper.vm.t1).to.equal(false) -expect(wrapper.vm.t2).to.equal('') +expect(wrapper.vm.t1).toEqual(false) +expect(wrapper.vm.t2).toEqual('') wrapperArray.setChecked() -expect(wrapper.vm.t1).to.equal(true) -expect(wrapper.vm.t2).to.equal('foo') +expect(wrapper.vm.t1).toEqual(true) +expect(wrapper.vm.t2).toEqual('foo') ``` diff --git a/docs/api/wrapper-array/setValue.md b/docs/api/wrapper-array/setValue.md index a584c6a3f..1a50d0f38 100644 --- a/docs/api/wrapper-array/setValue.md +++ b/docs/api/wrapper-array/setValue.md @@ -30,9 +30,9 @@ const wrapper = mount({ }) const wrapperArray = wrapper.findAll('.foo') -expect(wrapper.vm.t1).to.equal('') -expect(wrapper.vm.t2).to.equal('') +expect(wrapper.vm.t1).toEqual('') +expect(wrapper.vm.t2).toEqual('') wrapperArray.setValue('foo') -expect(wrapper.vm.t1).to.equal('foo') -expect(wrapper.vm.t2).to.equal('foo') +expect(wrapper.vm.t1).toEqual('foo') +expect(wrapper.vm.t2).toEqual('foo') ``` diff --git a/docs/ja/api/wrapper-array/setChecked.md b/docs/ja/api/wrapper-array/setChecked.md index ee936441a..9d2783ef8 100644 --- a/docs/ja/api/wrapper-array/setChecked.md +++ b/docs/ja/api/wrapper-array/setChecked.md @@ -31,9 +31,9 @@ const wrapper = mount({ }) const wrapperArray = wrapper.findAll('.foo') -expect(wrapper.vm.t1).to.equal(false) -expect(wrapper.vm.t2).to.equal('') +expect(wrapper.vm.t1).toEqual(false) +expect(wrapper.vm.t2).toEqual('') wrapperArray.setChecked() -expect(wrapper.vm.t1).to.equal(true) -expect(wrapper.vm.t2).to.equal('foo') +expect(wrapper.vm.t1).toEqual(true) +expect(wrapper.vm.t2).toEqual('foo') ``` diff --git a/docs/ja/api/wrapper-array/setValue.md b/docs/ja/api/wrapper-array/setValue.md index 2c8c5f918..80bb6ddaa 100644 --- a/docs/ja/api/wrapper-array/setValue.md +++ b/docs/ja/api/wrapper-array/setValue.md @@ -30,9 +30,9 @@ const wrapper = mount({ }) const wrapperArray = wrapper.findAll('.foo') -expect(wrapper.vm.t1).to.equal('') -expect(wrapper.vm.t2).to.equal('') +expect(wrapper.vm.t1).toEqual('') +expect(wrapper.vm.t2).toEqual('') wrapperArray.setValue('foo') -expect(wrapper.vm.t1).to.equal('foo') -expect(wrapper.vm.t2).to.equal('foo') +expect(wrapper.vm.t1).toEqual('foo') +expect(wrapper.vm.t2).toEqual('foo') ``` diff --git a/docs/ru/api/wrapper-array/setChecked.md b/docs/ru/api/wrapper-array/setChecked.md index bb5f389b7..ead59d2e6 100644 --- a/docs/ru/api/wrapper-array/setChecked.md +++ b/docs/ru/api/wrapper-array/setChecked.md @@ -31,9 +31,9 @@ const wrapper = mount({ }) const wrapperArray = wrapper.findAll('.foo') -expect(wrapper.vm.t1).to.equal(false) -expect(wrapper.vm.t2).to.equal('') +expect(wrapper.vm.t1).toEqual(false) +expect(wrapper.vm.t2).toEqual('') wrapperArray.setChecked() -expect(wrapper.vm.t1).to.equal(true) -expect(wrapper.vm.t2).to.equal('foo') +expect(wrapper.vm.t1).toEqual(true) +expect(wrapper.vm.t2).toEqual('foo') ``` diff --git a/docs/ru/api/wrapper-array/setValue.md b/docs/ru/api/wrapper-array/setValue.md index 53396c0dd..33d2cfb24 100644 --- a/docs/ru/api/wrapper-array/setValue.md +++ b/docs/ru/api/wrapper-array/setValue.md @@ -30,9 +30,9 @@ const wrapper = mount({ }) const wrapperArray = wrapper.findAll('.foo') -expect(wrapper.vm.t1).to.equal('') -expect(wrapper.vm.t2).to.equal('') +expect(wrapper.vm.t1).toEqual('') +expect(wrapper.vm.t2).toEqual('') wrapperArray.setValue('foo') -expect(wrapper.vm.t1).to.equal('foo') -expect(wrapper.vm.t2).to.equal('foo') +expect(wrapper.vm.t1).toEqual('foo') +expect(wrapper.vm.t2).toEqual('foo') ``` diff --git a/docs/zh/api/wrapper-array/setChecked.md b/docs/zh/api/wrapper-array/setChecked.md index d6cbfdaff..eb2a64c85 100644 --- a/docs/zh/api/wrapper-array/setChecked.md +++ b/docs/zh/api/wrapper-array/setChecked.md @@ -31,9 +31,9 @@ const wrapper = mount({ }) const wrapperArray = wrapper.findAll('.foo') -expect(wrapper.vm.t1).to.equal(false) -expect(wrapper.vm.t2).to.equal('') +expect(wrapper.vm.t1).toEqual(false) +expect(wrapper.vm.t2).toEqual('') wrapperArray.setChecked() -expect(wrapper.vm.t1).to.equal(true) -expect(wrapper.vm.t2).to.equal('foo') +expect(wrapper.vm.t1).toEqual(true) +expect(wrapper.vm.t2).toEqual('foo') ``` diff --git a/docs/zh/api/wrapper-array/setValue.md b/docs/zh/api/wrapper-array/setValue.md index 5d8007bbf..f6b1a2430 100644 --- a/docs/zh/api/wrapper-array/setValue.md +++ b/docs/zh/api/wrapper-array/setValue.md @@ -30,9 +30,9 @@ const wrapper = mount({ }) const wrapperArray = wrapper.findAll('.foo') -expect(wrapper.vm.t1).to.equal('') -expect(wrapper.vm.t2).to.equal('') +expect(wrapper.vm.t1).toEqual('') +expect(wrapper.vm.t2).toEqual('') wrapperArray.setValue('foo') -expect(wrapper.vm.t1).to.equal('foo') -expect(wrapper.vm.t2).to.equal('foo') +expect(wrapper.vm.t1).toEqual('foo') +expect(wrapper.vm.t2).toEqual('foo') ``` diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 000000000..bd8c60972 --- /dev/null +++ b/jest.config.js @@ -0,0 +1,9 @@ +module.exports = { + moduleNameMapper: { + '^~(.*)$': '/test/$1' + }, + transform: { + '.*\\.(vue)$': 'vue-jest', + '^.+\\.js$': '/node_modules/babel-jest' + } +} diff --git a/package.json b/package.json index 7e0e6dfd6..e0f2d2be1 100644 --- a/package.json +++ b/package.json @@ -95,13 +95,16 @@ "@commitlint/cli": "^8.2.0", "@commitlint/config-conventional": "^8.2.0", "@vue/composition-api": "^0.6.4", + "babel-jest": "^26.0.1", "commitizen": "^4.0.3", "cz-conventional-changelog": "^3.0.2", "husky": "^3.1.0", + "jest": "^26.0.1", "lint-staged": "^9.5.0", "prettier": "^1.16.0", "rollup-plugin-delete": "^1.2.0", - "rollup-plugin-replace": "^2.2.0" + "rollup-plugin-replace": "^2.2.0", + "vue-jest": "^4.0.0-beta.3" }, "config": { "commitizen": { diff --git a/test/setup/mocha.setup.js b/test/setup/mocha.setup.js index aea504407..e69de29bb 100644 --- a/test/setup/mocha.setup.js +++ b/test/setup/mocha.setup.js @@ -1,14 +0,0 @@ -require('@babel/polyfill') - -if (process.env.TEST_ENV !== 'node') { - require('jsdom-global')() -} - -const chai = require('chai') -const sinon = require('sinon') -const sinonChai = require('sinon-chai') - -chai.use(sinonChai) - -global.expect = chai.expect -global.sinon = sinon diff --git a/test/specs/components/RouterLink.spec.js b/test/specs/components/RouterLink.spec.js index 47f8e4373..0592b7591 100644 --- a/test/specs/components/RouterLink.spec.js +++ b/test/specs/components/RouterLink.spec.js @@ -26,14 +26,14 @@ describeWithShallowAndMount('RouterLinkStub', mountingMethod => { }) const routerLink = wrapper.find(RouterLinkStub) - expect(routerLink.props().to).to.equal('to1') - expect(routerLink.props().tag).to.equal('a') - expect(routerLink.props().exact).to.equal(true) - expect(routerLink.props().append).to.equal(true) - expect(routerLink.props().replace).to.equal(true) - expect(routerLink.props().activeClass).to.equal('activeClass1') - expect(routerLink.props().exactActiveClass).to.equal('exactActiveClass1') - expect(routerLink.props().event).to.equal('event1') + expect(routerLink.props().to).toEqual('to1') + expect(routerLink.props().tag).toEqual('a') + expect(routerLink.props().exact).toEqual(true) + expect(routerLink.props().append).toEqual(true) + expect(routerLink.props().replace).toEqual(true) + expect(routerLink.props().activeClass).toEqual('activeClass1') + expect(routerLink.props().exactActiveClass).toEqual('exactActiveClass1') + expect(routerLink.props().event).toEqual('event1') }) it('renders slot content', () => { @@ -49,6 +49,6 @@ describeWithShallowAndMount('RouterLinkStub', mountingMethod => { RouterLink: RouterLinkStub } }) - expect(wrapper.find(RouterLinkStub).text()).to.equal('some text') + expect(wrapper.find(RouterLinkStub).text()).toEqual('some text') }) }) diff --git a/test/specs/config.spec.js b/test/specs/config.spec.js index 4cdf3281a..7dd1c8965 100644 --- a/test/specs/config.spec.js +++ b/test/specs/config.spec.js @@ -40,8 +40,8 @@ describeWithShallowAndMount('config', mountingMethod => { t }) - expect(wrapper.vm.$t).to.equal('mock value') - expect(wrapper.text()).to.equal('mock value') + expect(wrapper.vm.$t).toEqual('mock value') + expect(wrapper.text()).toEqual('mock value') localVue.prototype.$t = undefined }) @@ -57,8 +57,8 @@ describeWithShallowAndMount('config', mountingMethod => { const wrapper = mountingMethod(testComponent) - expect(wrapper.vm.val()).to.equal('method') - expect(wrapper.text()).to.equal('method') + expect(wrapper.vm.val()).toEqual('method') + expect(wrapper.text()).toEqual('method') }) it("doesn't throw Vue warning when silent is set to true", () => { @@ -70,7 +70,7 @@ describeWithShallowAndMount('config', mountingMethod => { }, localVue }) - expect(wrapper.vm.prop1).to.equal('example') + expect(wrapper.vm.prop1).toEqual('example') wrapper.setProps({ prop1: 'new value' }) @@ -86,7 +86,7 @@ describeWithShallowAndMount('config', mountingMethod => { }, localVue }) - expect(wrapper.vm.prop1).to.equal('example') + expect(wrapper.vm.prop1).toEqual('example') wrapper.setProps({ prop1: 'new value' }) @@ -95,10 +95,10 @@ describeWithShallowAndMount('config', mountingMethod => { it('stubs out transitions by default', async () => { const wrapper = mountingMethod(ComponentWithTransitions) - expect(wrapper.find('[data-testid="expanded"]').exists()).to.equal(true) + expect(wrapper.find('[data-testid="expanded"]').exists()).toEqual(true) wrapper.setData({ expanded: true }) await wrapper.vm.$nextTick() - expect(wrapper.find('[data-testid="expanded"]').exists()).to.equal(false) + expect(wrapper.find('[data-testid="expanded"]').exists()).toEqual(false) }) it('allows control deprecation warnings visibility for name method', () => { diff --git a/test/specs/create-dom-event.spec.js b/test/specs/create-dom-event.spec.js index 263620425..ee47e243a 100644 --- a/test/specs/create-dom-event.spec.js +++ b/test/specs/create-dom-event.spec.js @@ -5,7 +5,7 @@ import { itDoNotRunIf } from 'conditional-specs' describe('createDOMEvent', () => { itDoNotRunIf(isRunningPhantomJS, 'returns cancelable event', () => { const event = createDOMEvent('click', {}) - expect(event.bubbles).to.equal(true) - expect(event.cancelable).to.equal(true) + expect(event.bubbles).toEqual(true) + expect(event.cancelable).toEqual(true) }) }) diff --git a/test/specs/create-local-vue.spec.js b/test/specs/create-local-vue.spec.js index 45c82d4f5..526f8ac69 100644 --- a/test/specs/create-local-vue.spec.js +++ b/test/specs/create-local-vue.spec.js @@ -23,7 +23,7 @@ describeWithShallowAndMount('createLocalVue', mountingMethod => { const wrapper = mountingMethod(Component, { localVue, store }) expect(wrapper.vm.$store).to.be.an('object') const freshWrapper = mountingMethod(Component) - expect(typeof freshWrapper.vm.$store).to.equal('undefined') + expect(typeof freshWrapper.vm.$store).toEqual('undefined') }) it('Vuex should work properly with local Vue', async () => { @@ -46,10 +46,10 @@ describeWithShallowAndMount('createLocalVue', mountingMethod => { }) const wrapper = mountingMethod(ComponentWithVuex, { localVue, store }) expect(wrapper.vm.$store).to.be.an('object') - expect(wrapper.text()).to.equal('0 1') + expect(wrapper.text()).toEqual('0 1') wrapper.trigger('click') await Vue.nextTick() - expect(wrapper.text()).to.equal('1 1') + expect(wrapper.text()).toEqual('1 1') }) it('installs Router without polluting global Vue', () => { @@ -62,7 +62,7 @@ describeWithShallowAndMount('createLocalVue', mountingMethod => { const wrapper = mountingMethod(Component, { localVue, router }) expect(wrapper.vm.$route).to.be.an('object') const freshWrapper = mountingMethod(Component) - expect(typeof freshWrapper.vm.$route).to.equal('undefined') + expect(typeof freshWrapper.vm.$route).toEqual('undefined') }) itDoNotRunIf( @@ -97,7 +97,7 @@ describeWithShallowAndMount('createLocalVue', mountingMethod => { expect(wrapper.text()).to.contain('foo') const freshWrapper = mountingMethod(Component) - expect(typeof freshWrapper.vm.$route).to.equal('undefined') + expect(typeof freshWrapper.vm.$route).toEqual('undefined') } ) @@ -106,7 +106,7 @@ describeWithShallowAndMount('createLocalVue', mountingMethod => { const pluginOptions = { foo: 'bar' } const plugin = { install: function(_Vue, options) { - expect(options).to.equal(pluginOptions) + expect(options).toEqual(pluginOptions) } } localVue.use(plugin, pluginOptions) @@ -118,7 +118,7 @@ describeWithShallowAndMount('createLocalVue', mountingMethod => { class Plugin {} Plugin.install = function(_Vue) { if (_Vue._installedPlugins) { - expect(_Vue._installedPlugins.indexOf(Plugin)).to.equal(-1) + expect(_Vue._installedPlugins.indexOf(Plugin)).toEqual(-1) } installCount++ } @@ -128,8 +128,8 @@ describeWithShallowAndMount('createLocalVue', mountingMethod => { localVue.use(Plugin) if (localVue._installedPlugins) { - expect(localVue._installedPlugins.indexOf(Plugin)).to.equal(0) + expect(localVue._installedPlugins.indexOf(Plugin)).toEqual(0) } - expect(installCount).to.equal(2) + expect(installCount).toEqual(2) }) }) diff --git a/test/specs/create-wrapper.spec.js b/test/specs/create-wrapper.spec.js index b2f1e35ae..0ee6d5841 100644 --- a/test/specs/create-wrapper.spec.js +++ b/test/specs/create-wrapper.spec.js @@ -8,14 +8,14 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'mount', () => { const Constructor = Vue.extend(Component) const vm = new Constructor().$mount() const wrapper = createWrapper(vm) - expect(wrapper.is(Component)).to.equal(true) + expect(wrapper.is(Component)).toEqual(true) expect(wrapper).instanceof(Wrapper) expect(wrapper.findAll('div')).instanceof(WrapperArray) }) it('handles HTMLElement', () => { const wrapper = createWrapper(document.createElement('div')) - expect(wrapper.is('div')).to.equal(true) + expect(wrapper.is('div')).toEqual(true) }) it('handles options', () => { @@ -24,6 +24,6 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'mount', () => { const wrapper = createWrapper(vm, { attachToDocument: true }) - expect(wrapper.options.attachToDocument).to.equal(true) + expect(wrapper.options.attachToDocument).toEqual(true) }) }) diff --git a/test/specs/error-wrapper.spec.js b/test/specs/error-wrapper.spec.js index 3357194c9..3f5723280 100644 --- a/test/specs/error-wrapper.spec.js +++ b/test/specs/error-wrapper.spec.js @@ -43,7 +43,7 @@ describeWithShallowAndMount('ErrorWrapper', mountingMethod => { const message = `[vue-test-utils]: find did not return ${selector}, cannot call ${method}() on empty Wrapper` const wrapper = mountingMethod(TestComponent) const error = wrapper.find(selector) - expect(error.constructor.name).to.equal('ErrorWrapper') + expect(error.constructor.name).toEqual('ErrorWrapper') expect(() => error[method]()) .to.throw() .with.property('message', message) diff --git a/test/specs/mount.spec.js b/test/specs/mount.spec.js index b7b0dc738..fff5fece2 100644 --- a/test/specs/mount.spec.js +++ b/test/specs/mount.spec.js @@ -39,7 +39,7 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'mount', () => { } const wrapper = mount(TestComponent) - expect(wrapper.findAll('p').length).to.equal(2) + expect(wrapper.findAll('p').length).toEqual(2) }) it('returns new VueWrapper with correct props data', () => { @@ -47,9 +47,9 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'mount', () => { const wrapper = mount(ComponentWithProps, { propsData: { prop1 } }) expect(wrapper.vm).to.be.an('object') if (wrapper.vm.$props) { - expect(wrapper.vm.$props.prop1).to.equal(prop1) + expect(wrapper.vm.$props.prop1).toEqual(prop1) } else { - expect(wrapper.vm.$options.propsData.prop1).to.equal(prop1) + expect(wrapper.vm.$options.propsData.prop1).toEqual(prop1) } }) @@ -76,7 +76,7 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'mount', () => { extends: BaseComponent } const wrapper = mount(TestComponent) - expect(wrapper.findAll('div').length).to.equal(1) + expect(wrapper.findAll('div').length).toEqual(1) }) it('handles nested uncompiled extended Vue component', () => { @@ -96,7 +96,7 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'mount', () => { extends: TestComponentC } const wrapper = mount(TestComponentD) - expect(wrapper.findAll('div').length).to.equal(1) + expect(wrapper.findAll('div').length).toEqual(1) }) itSkipIf( @@ -123,7 +123,7 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'mount', () => { } catch (err) { } finally { delete Vue.options.components['child-component'] - expect(wrapper.find(ChildComponent).exists()).to.equal(true) + expect(wrapper.find(ChildComponent).exists()).toEqual(true) } } ) @@ -131,11 +131,11 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'mount', () => { it('does not use cached component', () => { sandbox.stub(ComponentWithMixin.methods, 'someMethod') mount(ComponentWithMixin) - expect(ComponentWithMixin.methods.someMethod.callCount).to.equal(1) + expect(ComponentWithMixin.methods.someMethod.callCount).toEqual(1) ComponentWithMixin.methods.someMethod.restore() sandbox.stub(ComponentWithMixin.methods, 'someMethod') mount(ComponentWithMixin) - expect(ComponentWithMixin.methods.someMethod.callCount).to.equal(1) + expect(ComponentWithMixin.methods.someMethod.callCount).toEqual(1) }) it('throws an error if window is undefined', () => { @@ -159,7 +159,7 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'mount', () => { template: `
foo
` }) expect(wrapper.vm).to.be.an('object') - expect(wrapper.html()).to.equal(`
foo
`) + expect(wrapper.html()).toEqual(`
foo
`) }) itDoNotRunIf( @@ -175,7 +175,7 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'mount', () => { template: '#foo' }) expect(wrapper.vm).to.be.an('object') - expect(wrapper.html()).to.equal(`
foo
`) + expect(wrapper.html()).toEqual(`
foo
`) window.body.removeChild(template) } @@ -231,7 +231,7 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'mount', () => { template: '
' }) const wrapper = mount(TestComponent) - expect(wrapper.html()).to.equal(`
`) + expect(wrapper.html()).toEqual(`
`) }) itDoNotRunIf( @@ -246,7 +246,7 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'mount', () => { } const wrapper = mount(TestComponent) setTimeout(() => { - expect(wrapper.find(Component).exists()).to.equal(true) + expect(wrapper.find(Component).exists()).toEqual(true) done() }) } @@ -281,19 +281,19 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'mount', () => { } ) if (injectSupported) { - expect(typeof wrapper.vm.$options.provide).to.equal( + expect(typeof wrapper.vm.$options.provide).toEqual( vueVersion < 2.5 ? 'function' : 'object' ) } - expect(wrapper.vm.$options.attachToDocument).to.equal(undefined) - expect(wrapper.vm.$options.mocks).to.equal(undefined) - expect(wrapper.vm.$options.slots).to.equal(undefined) - expect(wrapper.vm.$options.localVue).to.equal(undefined) - expect(wrapper.vm.$options.stubs).to.equal(undefined) - expect(wrapper.vm.$options.context).to.equal(undefined) - expect(wrapper.vm.$options.attrs).to.equal(undefined) - expect(wrapper.vm.$options.listeners).to.equal(undefined) + expect(wrapper.vm.$options.attachToDocument).toEqual(undefined) + expect(wrapper.vm.$options.mocks).toEqual(undefined) + expect(wrapper.vm.$options.slots).toEqual(undefined) + expect(wrapper.vm.$options.localVue).toEqual(undefined) + expect(wrapper.vm.$options.stubs).toEqual(undefined) + expect(wrapper.vm.$options.context).toEqual(undefined) + expect(wrapper.vm.$options.attrs).toEqual(undefined) + expect(wrapper.vm.$options.listeners).toEqual(undefined) wrapper.destroy() }) @@ -362,7 +362,7 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'mount', () => { expect(wrapper.vm.$attrs).to.eql({ height: '50px', extra: 'attr' }) } - expect(wrapper.html()).to.equal( + expect(wrapper.html()).toEqual( '
\n' + '

prop1

\n' + '

\n' + @@ -394,7 +394,7 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'mount', () => { } } const wrapper = mount(Component, options) - expect(wrapper.text()).to.equal('aBC') + expect(wrapper.text()).toEqual('aBC') }) it('handles inline components', () => { @@ -411,7 +411,7 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'mount', () => { const wrapper = mount(TestComponent, { localVue }) - expect(wrapper.findAll(ChildComponent).length).to.equal(1) + expect(wrapper.findAll(ChildComponent).length).toEqual(1) }) it('handles nested components with extends', () => { @@ -449,7 +449,7 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'mount', () => { } } const wrapper = mount(Comp, { localVue }) - expect(wrapper.html()).to.equal('
composition api
') + expect(wrapper.html()).toEqual('
composition api
') }) itDoNotRunIf.skip( diff --git a/test/specs/mounting-options/attachTo.spec.js b/test/specs/mounting-options/attachTo.spec.js index ff519812a..1e1e20e5c 100644 --- a/test/specs/mounting-options/attachTo.spec.js +++ b/test/specs/mounting-options/attachTo.spec.js @@ -27,8 +27,8 @@ describeWithShallowAndMount('options.attachTo', mountingMethod => { expect(wrapper.vm.$el.parentNode).to.not.be.null expect(root).to.be.null expect(rendered).to.not.be.null - expect(rendered.outerHTML).to.equal(outerHTML) - expect(wrapper.options.attachedToDocument).to.equal(true) + expect(rendered.outerHTML).toEqual(outerHTML) + expect(wrapper.options.attachedToDocument).toEqual(true) wrapper.destroy() expect(document.getElementById('attach-to')).to.be.null }) @@ -47,8 +47,8 @@ describeWithShallowAndMount('options.attachTo', mountingMethod => { expect(wrapper.vm.$el.parentNode).to.not.be.null expect(root).to.be.null expect(rendered).to.not.be.null - expect(rendered.outerHTML).to.equal(outerHTML) - expect(wrapper.options.attachedToDocument).to.equal(true) + expect(rendered.outerHTML).toEqual(outerHTML) + expect(wrapper.options.attachedToDocument).toEqual(true) wrapper.destroy() expect(document.getElementById('attach-to')).to.be.null }) @@ -61,7 +61,7 @@ describeWithShallowAndMount('options.attachTo', mountingMethod => { div.setAttribute('data-server-rendered', 'true') div.innerHTML = innerHTML document.body.appendChild(div) - expect(div.outerHTML).to.equal(ssrHTML) + expect(div.outerHTML).toEqual(ssrHTML) const wrapper = mountingMethod(TestComponent, { attachTo: '#attach-to' }) @@ -69,8 +69,8 @@ describeWithShallowAndMount('options.attachTo', mountingMethod => { const rendered = document.getElementById('attach-to') expect(wrapper.vm.$el.parentNode).to.not.be.null expect(rendered).to.not.be.null - expect(rendered.outerHTML).to.equal(outerHTML) - expect(wrapper.options.attachedToDocument).to.equal(true) + expect(rendered.outerHTML).toEqual(outerHTML) + expect(wrapper.options.attachedToDocument).toEqual(true) wrapper.destroy() expect(document.getElementById('attach-to')).to.be.null }) diff --git a/test/specs/mounting-options/attachToDocument.spec.js b/test/specs/mounting-options/attachToDocument.spec.js index 97083e0cf..6b4175b64 100644 --- a/test/specs/mounting-options/attachToDocument.spec.js +++ b/test/specs/mounting-options/attachToDocument.spec.js @@ -10,7 +10,7 @@ describeWithShallowAndMount('options.attachToDocument', mountingMethod => { attachToDocument: true }) expect(document.querySelector('.attached')).to.not.equal(null) - expect(wrapper.options.attachedToDocument).to.equal(true) + expect(wrapper.options.attachedToDocument).toEqual(true) }) }) diff --git a/test/specs/mounting-options/attrs.spec.js b/test/specs/mounting-options/attrs.spec.js index c0282f82a..9ad08ab6c 100644 --- a/test/specs/mounting-options/attrs.spec.js +++ b/test/specs/mounting-options/attrs.spec.js @@ -20,8 +20,8 @@ describeWithShallowAndMount('options.attrs', mountingMethod => { anAttr: 'an attribute' } }) - expect(wrapper.vm.$attrs.anAttr).to.equal('an attribute') - expect(wrapper.vm.$attrs.anAttr).to.equal('an attribute') + expect(wrapper.vm.$attrs.anAttr).toEqual('an attribute') + expect(wrapper.vm.$attrs.anAttr).toEqual('an attribute') } ) diff --git a/test/specs/mounting-options/listeners.spec.js b/test/specs/mounting-options/listeners.spec.js index d9aabc859..298dd61c1 100644 --- a/test/specs/mounting-options/listeners.spec.js +++ b/test/specs/mounting-options/listeners.spec.js @@ -23,7 +23,7 @@ describeWithShallowAndMount('options.listeners', mountingMethod => { } ) - expect(wrapper.vm.$listeners.aListener.fns).to.equal(aListener) + expect(wrapper.vm.$listeners.aListener.fns).toEqual(aListener) } ) diff --git a/test/specs/mounting-options/localVue.spec.js b/test/specs/mounting-options/localVue.spec.js index 2ebd112b0..8e5b92490 100644 --- a/test/specs/mounting-options/localVue.spec.js +++ b/test/specs/mounting-options/localVue.spec.js @@ -137,7 +137,7 @@ describeWithShallowAndMount('options.localVue', mountingMethod => { localVue } ) - expect(localVue.options.created).to.equal(undefined) + expect(localVue.options.created).toEqual(undefined) }) it('handles merging Vue instances', () => { @@ -197,7 +197,7 @@ describeWithShallowAndMount('options.localVue', mountingMethod => { if (mountingMethod.name === 'renderToString') { return } - expect(wrapper.findAll(ChildComponent).length).to.equal(1) + expect(wrapper.findAll(ChildComponent).length).toEqual(1) } ) diff --git a/test/specs/mounting-options/mocks.spec.js b/test/specs/mounting-options/mocks.spec.js index d6b86db2e..8964278e4 100644 --- a/test/specs/mounting-options/mocks.spec.js +++ b/test/specs/mounting-options/mocks.spec.js @@ -138,9 +138,9 @@ describeWithShallowAndMount('options.mocks', mountingMethod => { $store } }) - expect(wrapper.vm.$store).to.equal($store) + expect(wrapper.vm.$store).toEqual($store) const freshWrapper = mountingMethod(Component) - expect(typeof freshWrapper.vm.$store).to.equal('undefined') + expect(typeof freshWrapper.vm.$store).toEqual('undefined') }) it('logs that a property cannot be overwritten if there are problems writing', () => { diff --git a/test/specs/mounting-options/provide.spec.js b/test/specs/mounting-options/provide.spec.js index 904958611..de9bca524 100644 --- a/test/specs/mounting-options/provide.spec.js +++ b/test/specs/mounting-options/provide.spec.js @@ -54,8 +54,8 @@ describeWithShallowAndMount('options.provide', mountingMethod => { } }) - expect(wrapper.vm.foo).to.equal('from parent') - expect(wrapper.vm.foo2).to.equal('from config') + expect(wrapper.vm.foo).toEqual('from parent') + expect(wrapper.vm.foo2).toEqual('from config') } ) @@ -81,8 +81,8 @@ describeWithShallowAndMount('options.provide', mountingMethod => { } }) - expect(wrapper.vm.foo).to.equal('from parent') - expect(wrapper.vm.foo2).to.equal('from config') + expect(wrapper.vm.foo).toEqual('from parent') + expect(wrapper.vm.foo2).toEqual('from config') } ) @@ -108,7 +108,7 @@ describeWithShallowAndMount('options.provide', mountingMethod => { } }) - expect(wrapper.vm.foo).to.equal('from config') + expect(wrapper.vm.foo).toEqual('from config') } ) @@ -137,7 +137,7 @@ describeWithShallowAndMount('options.provide', mountingMethod => { provide: { fromMount: '_' } }) - expect(wrapper.vm.setInBeforeCreate).to.equal('created') + expect(wrapper.vm.setInBeforeCreate).toEqual('created') } ) @@ -154,7 +154,7 @@ describeWithShallowAndMount('options.provide', mountingMethod => { localVue }) - expect(wrapper.vm.setInSetup).to.equal('created') + expect(wrapper.vm.setInSetup).toEqual('created') } ) diff --git a/test/specs/mounting-options/scopedSlots.spec.js b/test/specs/mounting-options/scopedSlots.spec.js index 2bd3fc2a3..d457801ee 100644 --- a/test/specs/mounting-options/scopedSlots.spec.js +++ b/test/specs/mounting-options/scopedSlots.spec.js @@ -28,7 +28,7 @@ describeWithShallowAndMount('scopedSlots', mountingMethod => { } } ) - expect(wrapper.html()).to.equal('
\n' + '

bar,123

\n' + '
') + expect(wrapper.html()).toEqual('
\n' + '

bar,123

\n' + '
') }) itDoNotRunIf(vueVersion < 2.1, 'handles render functions', () => { @@ -47,7 +47,7 @@ describeWithShallowAndMount('scopedSlots', mountingMethod => { } } ) - expect(wrapper.html()).to.equal('
\n' + '

bar

\n' + '
') + expect(wrapper.html()).toEqual('
\n' + '

bar

\n' + '
') }) itDoNotRunIf( @@ -70,7 +70,7 @@ describeWithShallowAndMount('scopedSlots', mountingMethod => { } } ) - expect(destructuringWrapper.html()).to.equal('

1,foo

') + expect(destructuringWrapper.html()).toEqual('

1,foo

') const notDestructuringWrapper = mountingMethod( { @@ -87,7 +87,7 @@ describeWithShallowAndMount('scopedSlots', mountingMethod => { } } ) - expect(notDestructuringWrapper.html()).to.equal('

1,foo

') + expect(notDestructuringWrapper.html()).toEqual('

1,foo

') } ) @@ -112,7 +112,7 @@ describeWithShallowAndMount('scopedSlots', mountingMethod => { } } ) - expect(destructuringWrapper.html()).to.equal('

1,foo

') + expect(destructuringWrapper.html()).toEqual('

1,foo

') const notDestructuringWrapper = mountingMethod( { @@ -130,7 +130,7 @@ describeWithShallowAndMount('scopedSlots', mountingMethod => { } } ) - expect(notDestructuringWrapper.html()).to.equal('

1,foo

') + expect(notDestructuringWrapper.html()).toEqual('

1,foo

') } ) @@ -145,54 +145,54 @@ describeWithShallowAndMount('scopedSlots', mountingMethod => { noProps: '

baz

' } }) - expect(wrapper.find('#destructuring').html()).to.equal( + expect(wrapper.find('#destructuring').html()).toEqual( '
\n' + '

0,1

\n' + '

1,2

\n' + '

2,3

\n' + '
' ) - expect(wrapper.find('#slots').html()).to.equal( + expect(wrapper.find('#slots').html()).toEqual( '
123
' ) - expect(wrapper.find('#list').html()).to.equal( + expect(wrapper.find('#list').html()).toEqual( '
\n' + '

0,a1

\n' + '

1,a2

\n' + '

2,a3

\n' + '
' ) - expect(wrapper.find('#single').html()).to.equal( + expect(wrapper.find('#single').html()).toEqual( '
\n' + '

abc

\n' + '
' ) - expect(wrapper.find('#noProps').html()).to.equal( + expect(wrapper.find('#noProps').html()).toEqual( '
\n' + '

baz

\n' + '
' ) wrapper.vm.items = [4, 5, 6] wrapper.vm.foo = [{ text: 'b1' }, { text: 'b2' }, { text: 'b3' }] wrapper.vm.bar = 'ABC' await Vue.nextTick() - expect(wrapper.find('#destructuring').html()).to.equal( + expect(wrapper.find('#destructuring').html()).toEqual( '
\n' + '

0,4

\n' + '

1,5

\n' + '

2,6

\n' + '
' ) - expect(wrapper.find('#slots').html()).to.equal( + expect(wrapper.find('#slots').html()).toEqual( '
123
' ) - expect(wrapper.find('#list').html()).to.equal( + expect(wrapper.find('#list').html()).toEqual( '
\n' + '

0,b1

\n' + '

1,b2

\n' + '

2,b3

\n' + '
' ) - expect(wrapper.find('#single').html()).to.equal( + expect(wrapper.find('#single').html()).toEqual( '
\n' + '

ABC

\n' + '
' ) - expect(wrapper.find('#noProps').html()).to.equal( + expect(wrapper.find('#noProps').html()).toEqual( '
\n' + '

baz

\n' + '
' ) }) @@ -213,7 +213,7 @@ describeWithShallowAndMount('scopedSlots', mountingMethod => { } } ) - expect(wrapper.html()).to.equal('
\n' + '

bar

\n' + '
') + expect(wrapper.html()).toEqual('
\n' + '

bar

\n' + '
') }) itDoNotRunIf(vueVersion < 2.5, 'handles no slot-scope', () => { @@ -230,7 +230,7 @@ describeWithShallowAndMount('scopedSlots', mountingMethod => { } } ) - expect(wrapper.html()).to.equal('
\n' + '

bar,123

\n' + '
') + expect(wrapper.html()).toEqual('
\n' + '

bar,123

\n' + '
') }) itDoNotRunIf( @@ -303,7 +303,7 @@ describeWithShallowAndMount('scopedSlots', mountingMethod => { '' } }) - expect(wrapper.html()).to.equal('
\n

25

\n

50

\n
') + expect(wrapper.html()).toEqual('
\n

25

\n

50

\n
') } ) @@ -327,7 +327,7 @@ describeWithShallowAndMount('scopedSlots', mountingMethod => { named: '' } }) - expect(wrapper.html()).to.equal('
\n

25

\n

50

\n
') + expect(wrapper.html()).toEqual('
\n

25

\n

50

\n
') } ) @@ -375,7 +375,7 @@ describeWithShallowAndMount('scopedSlots', mountingMethod => { ) wrapper.find('input').setValue('abc') - expect(wrapper.find('input').element.value).to.equal('abc') + expect(wrapper.find('input').element.value).toEqual('abc') } ) }) diff --git a/test/specs/mounting-options/slots.spec.js b/test/specs/mounting-options/slots.spec.js index 1fc2ddd9d..f1e5117a1 100644 --- a/test/specs/mounting-options/slots.spec.js +++ b/test/specs/mounting-options/slots.spec.js @@ -12,7 +12,7 @@ describeWithShallowAndMount('options.slots', mountingMethod => { const wrapper = mountingMethod(ComponentWithSlots, { slots: { default: Component } }) - expect(wrapper.contains(Component)).to.equal(true) + expect(wrapper.contains(Component)).toEqual(true) }) itDoNotRunIf( @@ -33,7 +33,7 @@ describeWithShallowAndMount('options.slots', mountingMethod => { }, localVue }) - expect(wrapper.contains('time')).to.equal(true) + expect(wrapper.contains('time')).toEqual(true) } ) @@ -41,7 +41,7 @@ describeWithShallowAndMount('options.slots', mountingMethod => { const wrapper = mountingMethod(ComponentWithSlots, { slots: { default: [Component] } }) - expect(wrapper.contains(Component)).to.equal(true) + expect(wrapper.contains(Component)).toEqual(true) }) it('mounts component with default slot if passed compiled options in slot object', () => { @@ -49,7 +49,7 @@ describeWithShallowAndMount('options.slots', mountingMethod => { const wrapper = mountingMethod(ComponentWithSlots, { slots: { default: [compiled] } }) - expect(wrapper.contains('#div')).to.equal(true) + expect(wrapper.contains('#div')).toEqual(true) }) itDoNotRunIf( @@ -59,7 +59,7 @@ describeWithShallowAndMount('options.slots', mountingMethod => { const wrapper = mountingMethod(ComponentWithSlots, { slots: { default: '' } }) - expect(wrapper.contains('span')).to.equal(true) + expect(wrapper.contains('span')).toEqual(true) } ) @@ -70,7 +70,7 @@ describeWithShallowAndMount('options.slots', mountingMethod => { const wrapper = mountingMethod(ComponentAsAClass, { slots: { default: '' } }) - expect(wrapper.contains('span')).to.equal(true) + expect(wrapper.contains('span')).toEqual(true) } ) @@ -84,7 +84,7 @@ describeWithShallowAndMount('options.slots', mountingMethod => { const wrapper = mountingMethod(ComponentWithSlots, { slots: { default: [Component] } }) - expect(wrapper.contains(Component)).to.equal(true) + expect(wrapper.contains(Component)).toEqual(true) window = windowSave // eslint-disable-line no-native-reassign } ) @@ -127,7 +127,7 @@ describeWithShallowAndMount('options.slots', mountingMethod => { const wrapper = mountingMethod(ComponentWithSlots, { slots: { default: [''] } }) - expect(wrapper.contains('span')).to.equal(true) + expect(wrapper.contains('span')).toEqual(true) } ) @@ -168,7 +168,7 @@ describeWithShallowAndMount('options.slots', mountingMethod => { footer: [Component] } }) - expect(wrapper.findAll(Component).length).to.equal(2) + expect(wrapper.findAll(Component).length).toEqual(2) }) it('mounts component with default and named slots', () => { @@ -214,8 +214,8 @@ describeWithShallowAndMount('options.slots', mountingMethod => { header: Component } }) - expect(wrapper.findAll(Component).length).to.equal(1) - expect(Array.isArray(wrapper.vm.$slots.header)).to.equal(true) + expect(wrapper.findAll(Component).length).toEqual(1) + expect(Array.isArray(wrapper.vm.$slots.header)).toEqual(true) }) it('mounts functional component with default slot if passed component in slot object', () => { @@ -227,7 +227,7 @@ describeWithShallowAndMount('options.slots', mountingMethod => { const wrapper = mountingMethod(TestComponent, { slots: { default: Component } }) - expect(wrapper.contains(Component)).to.equal(true) + expect(wrapper.contains(Component)).toEqual(true) }) it('mounts component with default slot if passed component in slot object', () => { @@ -239,7 +239,7 @@ describeWithShallowAndMount('options.slots', mountingMethod => { const wrapper = mountingMethod(TestComponent, { slots: { default: [Component] } }) - expect(wrapper.contains(Component)).to.equal(true) + expect(wrapper.contains(Component)).toEqual(true) }) it('mounts component with default slot if passed object with template prop in slot object', () => { @@ -252,7 +252,7 @@ describeWithShallowAndMount('options.slots', mountingMethod => { const wrapper = mountingMethod(TestComponent, { slots: { default: [compiled] } }) - expect(wrapper.contains('#div')).to.equal(true) + expect(wrapper.contains('#div')).toEqual(true) }) itDoNotRunIf( @@ -267,7 +267,7 @@ describeWithShallowAndMount('options.slots', mountingMethod => { const wrapper = mountingMethod(TestComponent, { slots: { default: '' } }) - expect(wrapper.contains('span')).to.equal(true) + expect(wrapper.contains('span')).toEqual(true) } ) @@ -277,7 +277,7 @@ describeWithShallowAndMount('options.slots', mountingMethod => { default: ['