Skip to content
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

WIP: Migrate to jest #1587

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
92cc81b
refactor: use jest
lmiller1990 Jun 20, 2020
9337c5b
refactor: strip flow types when running tests with jest
lmiller1990 Jun 20, 2020
ff0c01b
refactor: update attachTo and destroy specs
lmiller1990 Jun 20, 2020
b15aabd
refactor: continue moving to jest
lmiller1990 Jun 20, 2020
800a20c
refactor: update tests
lmiller1990 Jun 20, 2020
6c70bda
refactor: update tests
lmiller1990 Jun 20, 2020
f9f312a
refactor: update tests
lmiller1990 Jun 20, 2020
f96c675
refactor: continue jest migration
lmiller1990 Jun 20, 2020
2a3876c
refactor: continue jest migration
lmiller1990 Jun 20, 2020
88002f0
refactor: remove sinon
lmiller1990 Jun 20, 2020
39a8f65
refactor: update tests to use jest
lmiller1990 Jun 20, 2020
0583651
refactor: update tests to use jest
lmiller1990 Jun 20, 2020
54949f5
refactor: add jsx plugin and update scopedSlots spec
lmiller1990 Jun 20, 2020
d4d3549
chore: add missing deps
lmiller1990 Jun 30, 2020
4246c3a
test: add class component and update stubs tests
lmiller1990 Jul 5, 2020
4292a1b
test: update tests
lmiller1990 Jul 5, 2020
a96c5ff
test: migrate more tests
lmiller1990 Jul 5, 2020
1a80c9a
test: continue migration
lmiller1990 Jul 5, 2020
bd83932
test: refactor set methods
lmiller1990 Jul 5, 2020
04bf1a4
Merge branch 'dev' into migrate-to-jest
lmiller1990 Jul 5, 2020
79a0fc7
test: finish refactor set methods
lmiller1990 Jul 5, 2020
c62a8f7
test: refactor trigger
lmiller1990 Jul 5, 2020
1e8ebd4
test: refactor wrapper-array specs
lmiller1990 Jul 5, 2020
d38f9dc
test: update config.spec.js
lmiller1990 Jul 6, 2020
446e0ba
test: update mount specs
lmiller1990 Jul 6, 2020
a19b2c4
test: use spyOn
lmiller1990 Jul 6, 2020
eb1c859
test: migrate tests
lmiller1990 Jul 6, 2020
ec0fe23
test: placeholder to prevent false failure
lmiller1990 Jul 6, 2020
9b3d469
test: remove karma, sinon, chai and see what happens
lmiller1990 Jul 6, 2020
eb89bff
test: do not use compiled dist files for tests
lmiller1990 Jul 7, 2020
573fa6a
test: make scripts minimal
lmiller1990 Jul 7, 2020
b573899
test: update import paths
lmiller1990 Jul 9, 2020
92871b0
chore: update circleci
lmiller1990 Jul 9, 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
5 changes: 0 additions & 5 deletions .babelrc

This file was deleted.

28 changes: 2 additions & 26 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,31 +42,15 @@ jobs:
- run:
name: yarn bootstrap
command: yarn bootstrap
build_test:
<<: *defaults
steps:
- attach_workspace:
at: ~/repo
- *restore_node_modules
- run:
name: yarn build:test
command: yarn build:test
test:
<<: *defaults
steps:
- attach_workspace:
at: ~/repo
- *restore_node_modules
- run:
name: yarn test
command: yarn test
test_compat:
<<: *defaults
steps:
- attach_workspace:
at: ~/repo
- *restore_node_modules
- run: yarn test:compat
name: yarn test:unit
command: yarn test:unit
workflows:
version: 2
install-tests:
Expand All @@ -75,14 +59,6 @@ workflows:
- bootstrap:
requires:
- install
- build_test:
requires:
- install
- test:
requires:
- install
- test_compat:
requires:
- install
- build_test
- test
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"globals": {
"wrapper": true,
"expect": true,
"Element": true
"Element": true,
"jest": true
},
"root": true,
"plugins": [
Expand Down
18 changes: 18 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
plugins: [
'transform-flow-strip-types',
'transform-vue-jsx',
['@babel/plugin-proposal-decorators', { legacy: true }],
['@babel/plugin-proposal-class-properties', { loose: true }]
],
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current'
}
}
]
]
}
8 changes: 4 additions & 4 deletions docs/api/wrapper-array/setChecked.md
Original file line number Diff line number Diff line change
Expand Up @@ -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')
```
8 changes: 4 additions & 4 deletions docs/api/wrapper-array/setValue.md
Original file line number Diff line number Diff line change
Expand Up @@ -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')
```
8 changes: 4 additions & 4 deletions docs/ja/api/wrapper-array/setChecked.md
Original file line number Diff line number Diff line change
Expand Up @@ -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')
```
8 changes: 4 additions & 4 deletions docs/ja/api/wrapper-array/setValue.md
Original file line number Diff line number Diff line change
Expand Up @@ -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')
```
8 changes: 4 additions & 4 deletions docs/ru/api/wrapper-array/setChecked.md
Original file line number Diff line number Diff line change
Expand Up @@ -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')
```
8 changes: 4 additions & 4 deletions docs/ru/api/wrapper-array/setValue.md
Original file line number Diff line number Diff line change
Expand Up @@ -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')
```
8 changes: 4 additions & 4 deletions docs/zh/api/wrapper-array/setChecked.md
Original file line number Diff line number Diff line change
Expand Up @@ -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')
```
8 changes: 4 additions & 4 deletions docs/zh/api/wrapper-array/setValue.md
Original file line number Diff line number Diff line change
Expand Up @@ -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')
```
11 changes: 11 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
moduleNameMapper: {
'^~(.*)$': '<rootDir>/test/$1',
'^packages/(.*)$': '<rootDir>/packages/$1',
'\\.(css|less|scss|sass)$': 'identity-obj-proxy'
},
transform: {
'.*\\.(vue)$': 'vue-jest',
'^.+\\.js$': '<rootDir>/node_modules/babel-jest'
}
}
55 changes: 13 additions & 42 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,14 @@
],
"scripts": {
"bootstrap": "lerna bootstrap",
"build": "lerna run build",
"build:test": "lerna run build:test",
"clean": "lerna clean --yes",
"commit": "git-cz",
"docs": "vuepress dev docs",
"docs:build": "vuepress build docs",
"flow": "flow check",
"lint": "eslint --ext js,vue .",
"lint:docs": "eslint --ext js,vue,md docs --ignore-path .gitignore",
"lint:fix": "yarn lint -- --fix",
"format": "prettier --write \"**/*.{js,json,vue,md}\"",
"format:check": "prettier --check \"**/*.{js,json,vue,md}\"",
"release": "yarn build && yarn test:unit:only && lerna publish --conventional-commits -m \"chore(release): publish %s\"",
"test": "yarn format:check && yarn lint && yarn lint:docs && yarn flow && yarn test:types && yarn test:unit && yarn test:unit:karma && yarn test:unit:node",
"test:compat": "scripts/test-compat.sh",
"test:unit": "yarn build:test && yarn test:unit:only",
"test:unit:only": "mocha-webpack --webpack-config test/setup/webpack.test.config.js test/specs --recursive --require test/setup/mocha.setup.js",
"test:unit:only:dev": "cross-env TARGET=dev yarn test:unit:only",
"test:unit:debug": "yarn build:test && node --inspect-brk node_modules/.bin/mocha-webpack --webpack-config test/setup/webpack.test.config.js test/specs --recursive --require test/setup/mocha.setup.js",
"test:unit:karma": "yarn build:test && yarn test:unit:karma:only",
"test:unit:karma:only": "cross-env TARGET=browser karma start test/setup/karma.conf.js --single-run",
"test:unit:node": "yarn build:test && yarn test:unit:node:only",
"test:unit:node:only": "cross-env TEST_ENV=node mocha-webpack --webpack-config test/setup/webpack.test.config.js test/specs/render.spec.js test/specs/renderToString.spec.js --require test/setup/mocha.setup.js",
"test:unit": "cross-env TARGET=dev yarn jest",
"test:types": "tsc -p packages/test-utils/types && tsc -p packages/server-test-utils/types"
},
"dependencies": {
"babel-core": "^6.26.0",
"babel-eslint": "^8.2.2",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-loader": "^7.1.3",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-vue-jsx": "^3.7.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.6.0",
"babel-preset-flow-vue": "^1.0.0",
"babel-preset-stage-2": "^6.24.1",
"chai": "^4.0.0",
"chalk": "^2.4.2",
"conditional-specs": "^1.0.1",
"conventional-changelog": "^3.1.12",
Expand All @@ -56,13 +26,6 @@
"flow-bin": "^0.66.0",
"jsdom": "^12.0.0",
"jsdom-global": "^3.0.2",
"karma": "^3.1.4",
"karma-mocha": "^1.3.0",
"karma-phantomjs-launcher": "^1.0.4",
"karma-sinon-chai": "^2.0.2",
"karma-sourcemap-loader": "^0.3.7",
"karma-spec-reporter": "^0.0.31",
"karma-webpack": "^2.0.3",
"lerna": "^3.20.2",
"markdown-it-include": "^1.0.0",
"mocha": "^5.2.0",
Expand All @@ -74,12 +37,10 @@
"rollup-plugin-json": "4",
"rollup-plugin-node-resolve": "5",
"semver": "^6.3.0",
"sinon": "^7.2.3",
"sinon-chai": "^3.3.0",
"typescript": "3",
"vee-validate": "^2.1.3",
"vue": "^2.6.11",
"vue-class-component": "^6.1.2",
"vue-class-component": "^7.2.3",
"vue-loader": "^13.6.2",
"vue-router": "^3.0.1",
"vue-server-renderer": "^2.6.11",
Expand All @@ -91,16 +52,26 @@
"webpack-node-externals": "^1.6.0"
},
"devDependencies": {
"@babel/core": "^7.10.3",
"@babel/plugin-proposal-class-properties": "^7.10.1",
"@babel/plugin-proposal-decorators": "^7.10.3",
"@babel/preset-env": "^7.10.3",
"@commitlint/cli": "^8.2.0",
"@commitlint/config-conventional": "^8.2.0",
"@vue/composition-api": "^0.6.4",
"babel-jest": "^26.0.1",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-flow-strip-types": "^6.22.0",
"commitizen": "^4.0.3",
"cz-conventional-changelog": "^3.0.2",
"husky": "^3.1.0",
"identity-obj-proxy": "^3.0.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": {
Expand Down
4 changes: 2 additions & 2 deletions test/resources/utils.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* global describe */

import Vue from 'vue'
import { shallowMount, mount } from '@vue/test-utils'
import { renderToString } from '@vue/server-test-utils'
import { shallowMount, mount } from 'packages/test-utils/src'
import { renderToString } from 'packages/server-test-utils/src'

export const vueVersion = Number(
`${Vue.version.split('.')[0]}.${Vue.version.split('.')[1]}`
Expand Down
14 changes: 0 additions & 14 deletions test/setup/mocha.setup.js
Original file line number Diff line number Diff line change
@@ -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
20 changes: 10 additions & 10 deletions test/specs/components/RouterLink.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RouterLinkStub } from '@vue/test-utils'
import RouterLinkStub from '../.././../packages/test-utils/src/components/RouterLinkStub'
import { describeWithShallowAndMount } from '~resources/utils'

describeWithShallowAndMount('RouterLinkStub', mountingMethod => {
Expand Down Expand Up @@ -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', () => {
Expand All @@ -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')
})
})
Loading