diff --git a/.eslintrc b/.eslintrc index 297e042cfc3..71aefcfa96e 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,11 +1,6 @@ { - "env": { - "mocha": true - }, "globals": { - "ga": true, - "expect": true, - "sinon": true + "ga": true }, "plugins": ["html", "json"], "extends": "elemefe", diff --git a/.travis.yml b/.travis.yml index bac947919c8..4a38c75ba8f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,9 @@ sudo: false language: node_js -node_js: 8 +node_js: 10 +addons: + chrome: stable before_install: -- export CHROME_BIN=chromium-browser -- export DISPLAY=:99.0 -- sh -e /etc/init.d/xvfb start - export TRAVIS_COMMIT_MSG="[deploy] $(git log --format='%h - %B' --no-merges -n 1)" - export TRAVIS_COMMIT_USER="$(git log --no-merges -n 1 --format=%an)" - export TRAVIS_COMMIT_EMAIL="$(git log --no-merges -n 1 --format=%ae)" diff --git a/package.json b/package.json index 44f5b031495..a27c2fe0474 100644 --- a/package.json +++ b/package.json @@ -81,10 +81,11 @@ "babel-plugin-transform-vue-jsx": "^3.7.0", "babel-preset-env": "^1.7.0", "babel-preset-stage-2": "^6.24.1", - "chai": "^3.5.0", + "babel-regenerator-runtime": "^6.5.0", + "chai": "^4.2.0", "chokidar": "^1.7.0", "copy-webpack-plugin": "^5.0.0", - "coveralls": "^2.11.14", + "coveralls": "^3.0.3", "cp-cli": "^1.0.2", "cross-env": "^3.1.3", "css-loader": "^2.1.0", @@ -104,20 +105,20 @@ "html-webpack-plugin": "^3.2.0", "json-loader": "^0.5.7", "json-templater": "^1.0.4", - "karma": "^1.3.0", + "karma": "^4.0.1", "karma-chrome-launcher": "^2.2.0", - "karma-coverage": "^1.1.1", - "karma-mocha": "^1.2.0", - "karma-sinon-chai": "^1.2.4", + "karma-coverage": "^1.1.2", + "karma-mocha": "^1.3.0", + "karma-sinon-chai": "^2.0.2", "karma-sourcemap-loader": "^0.3.7", - "karma-spec-reporter": "0.0.26", - "karma-webpack": "^3.0.0", + "karma-spec-reporter": "^0.0.32", + "karma-webpack": "^3.0.5", "markdown-it": "^8.4.1", "markdown-it-anchor": "^5.0.2", "markdown-it-chain": "^1.3.0", "markdown-it-container": "^2.0.0", "mini-css-extract-plugin": "^0.4.1", - "mocha": "^3.1.1", + "mocha": "^6.0.2", "node-sass": "^4.11.0", "optimize-css-assets-webpack-plugin": "^5.0.1", "perspective.js": "^1.0.0", @@ -126,8 +127,8 @@ "rimraf": "^2.5.4", "sass-loader": "^7.1.0", "select-version-cli": "^0.0.2", - "sinon": "^1.17.6", - "sinon-chai": "^2.8.0", + "sinon": "^7.2.7", + "sinon-chai": "^3.3.0", "style-loader": "^0.23.1", "transliteration": "^1.1.11", "uglifyjs-webpack-plugin": "^2.1.1", diff --git a/test/.eslintrc b/test/.eslintrc new file mode 100644 index 00000000000..32ff361127f --- /dev/null +++ b/test/.eslintrc @@ -0,0 +1,13 @@ +{ + "env": { + "mocha": true, + "es6": true + }, + "globals": { + "expect": true, + "sinon": true + }, + "parserOptions": { + "ecmaVersion": 2017 + } +} diff --git a/test/unit/index.js b/test/unit/index.js index facac592fdb..fe3fcefbe93 100644 --- a/test/unit/index.js +++ b/test/unit/index.js @@ -1,6 +1,4 @@ -// Polyfill fn.bind() for PhantomJS -/* eslint-disable no-extend-native */ -Function.prototype.bind = require('function-bind'); +require('babel-regenerator-runtime'); // add regenerator support for async await require('packages/theme-chalk/lib/index.css'); // require all test files (files that ends with .spec.js) diff --git a/test/unit/karma.conf.js b/test/unit/karma.conf.js index e216c8756ea..73374ca30d6 100644 --- a/test/unit/karma.conf.js +++ b/test/unit/karma.conf.js @@ -2,13 +2,7 @@ const webpackConfig = require('../../build/webpack.test'); module.exports = function(config) { const configuration = { - browsers: ['Chrome'], - customLaunchers: { - Chrome_travis_ci: { - base: 'Chrome', - flags: ['--no-sandbox'] - } - }, + browsers: ['ChromeHeadless'], frameworks: ['mocha', 'sinon-chai'], reporters: ['spec', 'coverage'], files: ['./index.js'], @@ -33,9 +27,5 @@ module.exports = function(config) { } }; - if (process.env.TRAVIS) { - configuration.browsers = ['Chrome_travis_ci']; - } - config.set(configuration); }; diff --git a/test/unit/specs/date-picker.spec.js b/test/unit/specs/date-picker.spec.js index ae2edb973b7..3b818e5c5cd 100644 --- a/test/unit/specs/date-picker.spec.js +++ b/test/unit/specs/date-picker.spec.js @@ -2,7 +2,8 @@ import { createTest, createVue, destroyVM, - triggerEvent + triggerEvent, + wait } from '../util'; import DatePicker from 'packages/date-picker'; @@ -21,16 +22,14 @@ const keyDown = (el, keyCode) => { describe('DatePicker', () => { let vm; - afterEach(() => { - destroyVM(vm); - }); + afterEach(() => { destroyVM(vm); }); it('create', () => { vm = createTest(DatePicker, { readonly: true, placeholder: '23333', format: 'HH-mm-ss' - }); + }, true); const input = vm.$el.querySelector('input'); expect(input.getAttribute('placeholder')).to.equal('23333'); @@ -319,9 +318,7 @@ describe('DatePicker', () => { describe('input event', () => { // mimic standard