张恒

更新依赖删除单元测试

1 -# Commented sections below can be used to run tests on the CI server
2 -# https://simulatedgreg.gitbooks.io/electron-vue/content/en/testing.html#on-the-subject-of-ci-testing
3 -osx_image: xcode8.3
4 -sudo: required
5 -dist: trusty
6 -language: c
7 -matrix:
8 - include:
9 - - os: osx
10 - - os: linux
11 - env: CC=clang CXX=clang++ npm_config_clang=1
12 - compiler: clang
13 -cache:
14 - directories:
15 - - node_modules
16 - - "$HOME/.electron"
17 - - "$HOME/.cache"
18 -addons:
19 - apt:
20 - packages:
21 - - libgnome-keyring-dev
22 - - icnsutils
23 - #- xvfb
24 -before_install:
25 -- mkdir -p /tmp/git-lfs && curl -L https://github.com/github/git-lfs/releases/download/v1.2.1/git-lfs-$([
26 - "$TRAVIS_OS_NAME" == "linux" ] && echo "linux" || echo "darwin")-amd64-1.2.1.tar.gz
27 - | tar -xz -C /tmp/git-lfs --strip-components 1 && /tmp/git-lfs/git-lfs pull
28 -- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install --no-install-recommends -y icnsutils graphicsmagick xz-utils; fi
29 -install:
30 -#- export DISPLAY=':99.0'
31 -#- Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
32 -- nvm install 7
33 -- curl -o- -L https://yarnpkg.com/install.sh | bash
34 -- source ~/.bashrc
35 -- npm install -g xvfb-maybe
36 -- yarn
37 -script:
38 -#- xvfb-maybe node_modules/.bin/karma start test/unit/karma.conf.js
39 -#- yarn run pack && xvfb-maybe node_modules/.bin/mocha test/e2e
40 -- yarn run build
41 -branches:
42 - only:
43 - - master
1 -# Commented sections below can be used to run tests on the CI server
2 -# https://simulatedgreg.gitbooks.io/electron-vue/content/en/testing.html#on-the-subject-of-ci-testing
3 -version: 0.1.{build}
4 -
5 -branches:
6 - only:
7 - - master
8 -
9 -image: Visual Studio 2017
10 -platform:
11 - - x64
12 -
13 -cache:
14 - - node_modules
15 - - '%APPDATA%\npm-cache'
16 - - '%USERPROFILE%\.electron'
17 - - '%USERPROFILE%\AppData\Local\Yarn\cache'
18 -
19 -init:
20 - - git config --global core.autocrlf input
21 -
22 -install:
23 - - ps: Install-Product node 8 x64
24 - - git reset --hard HEAD
25 - - yarn
26 - - node --version
27 -
28 -build_script:
29 - #- yarn test
30 - - yarn build
31 -
32 -test: off
...@@ -14,12 +14,9 @@ ...@@ -14,12 +14,9 @@
14 "build:clean": "cross-env BUILD_TARGET=clean node .electron-vue/build.js", 14 "build:clean": "cross-env BUILD_TARGET=clean node .electron-vue/build.js",
15 "build:web": "cross-env BUILD_TARGET=web node .electron-vue/build.js", 15 "build:web": "cross-env BUILD_TARGET=web node .electron-vue/build.js",
16 "dev": "node .electron-vue/dev-runner.js", 16 "dev": "node .electron-vue/dev-runner.js",
17 - "e2e": "npm run pack && mocha test/e2e",
18 "pack": "npm run pack:main && npm run pack:renderer", 17 "pack": "npm run pack:main && npm run pack:renderer",
19 "pack:main": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.main.config.js", 18 "pack:main": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.main.config.js",
20 - "pack:renderer": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.renderer.config.js", 19 + "pack:renderer": "cross-env NODE_ENV=production webpack --progress --colors --config .electron-vue/webpack.renderer.config.js"
21 - "test": "npm run unit && npm run e2e",
22 - "unit": "karma start test/unit/karma.conf.js"
23 }, 20 },
24 "build": { 21 "build": {
25 "productName": "electron-vue-admin", 22 "productName": "electron-vue-admin",
...@@ -31,7 +28,8 @@ ...@@ -31,7 +28,8 @@
31 "dist/electron/**/*" 28 "dist/electron/**/*"
32 ], 29 ],
33 "dmg": { 30 "dmg": {
34 - "contents": [{ 31 + "contents": [
32 + {
35 "x": 410, 33 "x": 410,
36 "y": 150, 34 "y": 150,
37 "type": "link", 35 "type": "link",
...@@ -73,22 +71,20 @@ ...@@ -73,22 +71,20 @@
73 "babel-eslint": "^8.2.3", 71 "babel-eslint": "^8.2.3",
74 "babel-loader": "^7.1.4", 72 "babel-loader": "^7.1.4",
75 "babel-plugin-dynamic-import-webpack": "^1.1.0", 73 "babel-plugin-dynamic-import-webpack": "^1.1.0",
76 - "babel-plugin-istanbul": "^4.1.6",
77 "babel-plugin-transform-runtime": "^6.23.0", 74 "babel-plugin-transform-runtime": "^6.23.0",
78 "babel-preset-env": "^1.7.0", 75 "babel-preset-env": "^1.7.0",
79 "babel-preset-stage-0": "^6.24.1", 76 "babel-preset-stage-0": "^6.24.1",
80 "babel-register": "^6.26.0", 77 "babel-register": "^6.26.0",
81 "babili-webpack-plugin": "^0.1.2", 78 "babili-webpack-plugin": "^0.1.2",
82 "cfonts": "^2.1.2", 79 "cfonts": "^2.1.2",
83 - "chai": "^4.1.2",
84 "chalk": "^2.4.1", 80 "chalk": "^2.4.1",
85 "copy-webpack-plugin": "^4.5.1", 81 "copy-webpack-plugin": "^4.5.1",
86 "cross-env": "^5.1.6", 82 "cross-env": "^5.1.6",
87 "css-loader": "^3.1.0", 83 "css-loader": "^3.1.0",
88 "del": "^5.0.0", 84 "del": "^5.0.0",
89 "devtron": "^1.4.0", 85 "devtron": "^1.4.0",
90 - "electron": "^5.0.7", 86 + "electron": "^6.0.1",
91 - "electron-builder": "^21.1.1", 87 + "electron-builder": "^21.2.0",
92 "electron-debug": "^3.0.1", 88 "electron-debug": "^3.0.1",
93 "electron-devtools-installer": "^2.2.4", 89 "electron-devtools-installer": "^2.2.4",
94 "eslint": "^4.19.1", 90 "eslint": "^4.19.1",
...@@ -102,23 +98,9 @@ ...@@ -102,23 +98,9 @@
102 "eslint-plugin-standard": "^3.1.0", 98 "eslint-plugin-standard": "^3.1.0",
103 "file-loader": "^1.1.11", 99 "file-loader": "^1.1.11",
104 "html-webpack-plugin": "^3.2.0", 100 "html-webpack-plugin": "^3.2.0",
105 - "inject-loader": "^4.0.1",
106 - "karma": "^2.0.2",
107 - "karma-chai": "^0.1.0",
108 - "karma-coverage": "^1.1.2",
109 - "karma-electron": "^6.0.0",
110 - "karma-mocha": "^1.3.0",
111 - "karma-sourcemap-loader": "^0.3.7",
112 - "karma-spec-reporter": "^0.0.32",
113 - "karma-webpack": "^3.0.0",
114 "mini-css-extract-plugin": "0.8.0", 101 "mini-css-extract-plugin": "0.8.0",
115 - "mocha": "^5.2.0",
116 - "multispinner": "^0.2.1",
117 - "node-loader": "^0.6.0",
118 "node-sass": "^4.12.0", 102 "node-sass": "^4.12.0",
119 - "require-dir": "^1.0.0",
120 "sass-loader": "^7.0.3", 103 "sass-loader": "^7.0.3",
121 - "spectron": "^3.8.0",
122 "style-loader": "^0.21.0", 104 "style-loader": "^0.21.0",
123 "svg-sprite-loader": "^4.1.6", 105 "svg-sprite-loader": "^4.1.6",
124 "url-loader": "^2.1.0", 106 "url-loader": "^2.1.0",
...@@ -132,4 +114,4 @@ ...@@ -132,4 +114,4 @@
132 "webpack-hot-middleware": "^2.25.0", 114 "webpack-hot-middleware": "^2.25.0",
133 "webpack-merge": "^4.2.1" 115 "webpack-merge": "^4.2.1"
134 } 116 }
135 -}
...\ No newline at end of file ...\ No newline at end of file
117 +}
......
1 -{
2 - "env": {
3 - "mocha": true
4 - },
5 - "globals": {
6 - "assert": true,
7 - "expect": true,
8 - "should": true,
9 - "__static": true
10 - }
11 -}
1 -'use strict'
2 -
3 -// Set BABEL_ENV to use proper env config
4 -process.env.BABEL_ENV = 'test'
5 -
6 -// Enable use of ES6+ on required files
7 -require('babel-register')({
8 - ignore: /node_modules/
9 -})
10 -
11 -// Attach Chai APIs to global scope
12 -const { expect, should, assert } = require('chai')
13 -global.expect = expect
14 -global.should = should
15 -global.assert = assert
16 -
17 -// Require all JS files in `./specs` for Mocha to consume
18 -require('require-dir')('./specs')
1 -import utils from '../utils'
2 -
3 -describe('Launch', function () {
4 - beforeEach(utils.beforeEach)
5 - afterEach(utils.afterEach)
6 -
7 - it('shows the proper application title', function () {
8 - return this.app.client.getTitle()
9 - .then(title => {
10 - expect(title).to.equal('my-project')
11 - })
12 - })
13 -})
1 -import electron from 'electron'
2 -import { Application } from 'spectron'
3 -
4 -export default {
5 - afterEach () {
6 - this.timeout(10000)
7 -
8 - if (this.app && this.app.isRunning()) {
9 - return this.app.stop()
10 - }
11 - },
12 - beforeEach () {
13 - this.timeout(10000)
14 - this.app = new Application({
15 - path: electron,
16 - args: ['dist/electron/main.js'],
17 - startTimeout: 10000,
18 - waitTimeout: 10000
19 - })
20 -
21 - return this.app.start()
22 - }
23 -}
1 -import Vue from 'vue'
2 -Vue.config.devtools = false
3 -Vue.config.productionTip = false
4 -
5 -// require all test files (files that ends with .spec.js)
6 -const testsContext = require.context('./specs', true, /\.spec$/)
7 -testsContext.keys().forEach(testsContext)
8 -
9 -// require all src files except main.js for coverage.
10 -// you can also change this to match only the subset of files that
11 -// you want coverage for.
12 -const srcContext = require.context('../../src/renderer', true, /^\.\/(?!main(\.js)?$)/)
13 -srcContext.keys().forEach(srcContext)
1 -'use strict'
2 -
3 -const path = require('path')
4 -const merge = require('webpack-merge')
5 -const webpack = require('webpack')
6 -
7 -const baseConfig = require('../../.electron-vue/webpack.renderer.config')
8 -const projectRoot = path.resolve(__dirname, '../../src/renderer')
9 -
10 -// Set BABEL_ENV to use proper preset config
11 -process.env.BABEL_ENV = 'test'
12 -
13 -let webpackConfig = merge(baseConfig, {
14 - devtool: '#inline-source-map',
15 - plugins: [
16 - new webpack.DefinePlugin({
17 - 'process.env.NODE_ENV': '"testing"'
18 - })
19 - ]
20 -})
21 -
22 -// don't treat dependencies as externals
23 -delete webpackConfig.entry
24 -delete webpackConfig.externals
25 -delete webpackConfig.output.libraryTarget
26 -
27 -// apply vue option to apply isparta-loader on js
28 -webpackConfig.module.rules
29 - .find(rule => rule.use.loader === 'vue-loader').use.options.loaders.js = 'babel-loader'
30 -
31 -module.exports = config => {
32 - config.set({
33 - browsers: ['visibleElectron'],
34 - client: {
35 - useIframe: false
36 - },
37 - coverageReporter: {
38 - dir: './coverage',
39 - reporters: [
40 - { type: 'lcov', subdir: '.' },
41 - { type: 'text-summary' }
42 - ]
43 - },
44 - customLaunchers: {
45 - 'visibleElectron': {
46 - base: 'Electron',
47 - flags: ['--show']
48 - }
49 - },
50 - frameworks: ['mocha', 'chai'],
51 - files: ['./index.js'],
52 - preprocessors: {
53 - './index.js': ['webpack', 'sourcemap']
54 - },
55 - reporters: ['spec', 'coverage'],
56 - singleRun: true,
57 - webpack: webpackConfig,
58 - webpackMiddleware: {
59 - noInfo: true
60 - }
61 - })
62 -}
1 -import Vue from 'vue'
2 -import LandingPage from '@/components/LandingPage'
3 -
4 -describe('LandingPage.vue', () => {
5 - it('should render correct contents', () => {
6 - const vm = new Vue({
7 - el: document.createElement('div'),
8 - render: h => h(LandingPage)
9 - }).$mount()
10 -
11 - expect(vm.$el.querySelector('.title').textContent).to.contain('Welcome to your new project!')
12 - })
13 -})