Open mowatermelon opened 6 years ago
Hello.spec.js
修改前
import Vue from 'vue'
import Hello from '@/components/Hello'
describe('Hello.vue', () => {
it('should render correct contents', () => {
const Constructor = Vue.extend(Hello)
const vm = new Constructor().$mount()
expect(vm.$el.querySelector('.hello h1').textContent)
.to.equal('Welcome to Your Vue.js App')
})
})
修改后
import Vue from 'vue'
import Hello from '@/pages/Hello'
describe('Hello.vue', () => {
it('should render correct contents', () => {
const Constructor = Vue.extend(Hello)
const vm = new Constructor().$mount()
expect(vm.$el.querySelector('p.alert-success').textContent)
.to.equal('由西瓜酱提供包含三种颜色主题的vue后台操作模板')
})
})
npm run unit
提示[vuex] vuex requires a Promise polyfill in this browser.
,即我应该要装一个babel-polyfill
的依赖包
babel-polyfill
cnpm i babel-polyfill -S
build/webpack.base.conf.js
文件中module.exports = {
entry: {
app: './src/main.js'
}
}
// 替换为
module.exports = {
entry: {
app: ["babel-polyfill", "./src/main.js"]
}
};
npm run unit
卒,报错和上文一样
$ cnpm i
/ [56/74] Installing string-width@^1.0.2platform unsupported babel-cli@6.26.0 › chokidar@1.7.0 › fsevents@^1.0.0 Package require os(darwin) not compatible with your platform(win32)
[fsevents@^1.0.0] optional install error: Package require os(darwin) not compatible with your platform(win32)
√ Installed 74 packages
√ Linked 884 latest versions
Downloading https://tnpm-hz.oss-cn-hangzhou.aliyuncs.com/dist/chromedriver/2.37/chromedriver_win32.zip
Saving to D:\Users\ADMINI~1\AppData\Local\Temp\chromedriver\chromedriver_win32.zip
Received 781K...
Received 1563K...
Received 2345K...
Received 3127K...
Received 3270K total.
Extracting zip contents
Copying to target path F:\documentbak\4_18\bak\vue-esri\node_modules\_chromedriver@2.37.0@chromedriver\lib\chromedriver
Done. ChromeDriver binary available at F:\documentbak\4_18\bak\vue-esri\node_modules\_chromedriver@2.37.0@chromedriver\lib\chromedriver\chromedriver.exe
PhantomJS not found on PATH
Download already available at D:\Users\ADMINI~1\AppData\Local\Temp\phantomjs\phantomjs-2.1.1-windows.zip
Verified checksum of previously downloaded file
Extracting zip contents
Removing F:\documentbak\4_18\bak\vue-esri\node_modules\_phantomjs-prebuilt@2.1.16@phantomjs-prebuilt\lib\phantom
Copying extracted folder D:\Users\ADMINI~1\AppData\Local\Temp\phantomjs\phantomjs-2.1.1-windows.zip-extract-1524025590466\phantomjs-2.1.1-windows -> F:\documentbak\4_18\bak\vue-esri\node_modules\_phantomjs-prebuilt@2.1.16@phantomjs-prebuilt\lib\phantom
Writing location.js file
Done. Phantomjs binary available at F:\documentbak\4_18\bak\vue-esri\node_modules\_phantomjs-prebuilt@2.1.16@phantomjs-prebuilt\lib\phantom\bin\phantomjs.exe
Cached binary found at D:\Users\Administrator\.npminstall_tarball\node-sass\4.8.3\win32-x64-57_binding.node
Binary found at F:\documentbak\4_18\bak\vue-esri\node_modules\_node-sass@4.8.3@node-sass\vendor\win32-x64-57\binding.node
Testing binary
Binary is fine
√ Run 3 scripts
peerDependencies link ajv@4.11.8 in F:\documentbak\4_18\bak\vue-esri\node_modules\_ajv-keywords@1.5.1@ajv-keywords unmet with F:\documentbak\4_18\bak\vue-esri\node_modules\ajv(5.5.2)
anti semver karma@1.7.1 › useragent@2.3.0 › tmp@0.0.x delcares tmp@0.0.x(resolved as 0.0.33) but using ancestor(karma)'s dependency tmp@0.0.31(resolved as 0.0.31)
deprecate nightwatch@0.9.20 › proxy-agent@2.0.0 › socks-proxy-agent@2.1.1 › socks@~1.1.5 If using 2.x branch, please upgrade to at least 2.1.6 to avoid a serious bug with socket data flow and an import issue introduced in 2.1.0
deprecate karma-sinon-chai@1.3.4 › sinon@2.4.1 › formatio@1.2.0 This package is unmaintained. Use @sinonjs/formatio instead
Recently updated (since 2018-04-11): 22 packages (detail see file F:\documentbak\4_18\bak\vue-esri\node_modules\.recently_updates.txt)
Today:
→ copy-webpack-plugin@4.5.1 › serialize-javascript@^1.4.0(1.5.0) (08:08:05)
→ babel-loader@6.4.1 › webpack@2.7.0 › node-libs-browser@2.1.0 › timers-browserify@^2.0.4(2.0.9) (06:26:13)
→ babel-loader@6.4.1 › webpack@2.7.0 › node-libs-browser@2.1.0 › buffer@4.9.1 › base64-js@^1.0.2(1.3.0) (07:11:58)
√ All packages installed (1127 packages installed from npm registry, used 1m, speed 167.57kB/s, json 958(13.45MB), tarball 0B)
build/webpack.base.conf.js
文件中import babel-polyfill
,然后执行单元测试,失败build/webpack.base.conf.js
文件的babel-loader
配置修改前
{
test: /\.js$/,
loader: 'babel-loader',
include: [resolve('src'), resolve('test')]
},
修改后
{
test: /\.js$/,
loader: 'babel-loader',
query: {
plugins: [
"transform-runtime"
],
presets: ['es2015', 'stage-0']
},
include: [resolve('src'), resolve('test')]
},
$ npm run unit
> vue-esri@1.0.1 unit F:\documentbak\4_18\bak\vue-esri
> cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run
(node:9264) DeprecationWarning: loaderUtils.parseQuery() received a non-string value which can be problematic, see https://github.com/webpack/loader-utils/issues/56
parseQuery() will be replaced with getOptions() in the next major version of loader-utils.
Hash: cfc91bc079f6419d2ae5
Version: webpack 2.7.0
Time: 1824ms
Asset Size Chunks Chunk Names
index.js 8.14 kB 0 [emitted] index.js
chunk {0} index.js (index.js) 1.78 kB [entry] [rendered]
[0] ./test/unit/index.js 1.78 kB {0} [built] [failed] [1 error]
ERROR in ./test/unit/index.js
Module build failed: Error: Couldn't find preset "es2015" relative to directory "F:\\documentbak\\4_18\\bak\\vue-esri\\test\\unit"
at F:\documentbak\4_18\bak\vue-esri\node_modules\_babel-core@6.26.0@babel-core\lib\transformation\file\options\option-manager.js:293:19
at Array.map (<anonymous>)
at OptionManager.resolvePresets (F:\documentbak\4_18\bak\vue-esri\node_modules\_babel-core@6.26.0@babel-core\lib\transformation\file\options\option-manager.js:275:20)
at OptionManager.mergePresets (F:\documentbak\4_18\bak\vue-esri\node_modules\_babel-core@6.26.0@babel-core\lib\transformation\file\options\option-manager.js:264:10)
at OptionManager.mergeOptions (F:\documentbak\4_18\bak\vue-esri\node_modules\_babel-core@6.26.0@babel-core\lib\transformation\file\options\option-manager.js:249:14)
at OptionManager.init (F:\documentbak\4_18\bak\vue-esri\node_modules\_babel-core@6.26.0@babel-core\lib\transformation\file\options\option-manager.js:368:12)
at File.initOptions (F:\documentbak\4_18\bak\vue-esri\node_modules\_babel-core@6.26.0@babel-core\lib\transformation\file\index.js:212:65)
at new File (F:\documentbak\4_18\bak\vue-esri\node_modules\_babel-core@6.26.0@babel-core\lib\transformation\file\index.js:135:24)
at Pipeline.transform (F:\documentbak\4_18\bak\vue-esri\node_modules\_babel-core@6.26.0@babel-core\lib\transformation\pipeline.js:46:16)
at transpile (F:\documentbak\4_18\bak\vue-esri\node_modules\_babel-loader@6.4.1@babel-loader\lib\index.js:46:20)
at Object.module.exports (F:\documentbak\4_18\bak\vue-esri\node_modules\_babel-loader@6.4.1@babel-loader\lib\index.js:163:20)
18 04 2018 13:52:39.219:INFO [karma]: Karma v1.7.1 server started at http://0.0.0.0:9876/
18 04 2018 13:52:39.225:INFO [launcher]: Launching browser PhantomJS with unlimited concurrency
18 04 2018 13:52:39.244:INFO [launcher]: Starting browser PhantomJS
18 04 2018 13:52:43.309:INFO [PhantomJS 2.1.1 (Windows 7.0.0)]: Connected on socket NX2qUTX-O7gNA8qwAAAA with id 28537933
18 04 2018 13:52:43.916:WARN [reporter]: SourceMap position not found for trace: undefined
PhantomJS 2.1.1 (Windows 7.0.0) ERROR
Error: Module build failed: Error: Couldn't find preset "es2015" relative to directory "F:\\documentbak\\4_18\\bak\\vue-esri\\test\\unit"
at F:\documentbak\4_18\bak\vue-esri\node_modules\_babel-core@6.26.0@babel-core\lib\transformation\file\options\option-manager.js:293:19
at Array.map (<anonymous>)
at OptionManager.resolvePresets (F:\documentbak\4_18\bak\vue-esri\node_modules\_babel-core@6.26.0@babel-core\lib\transformation\file\options\option-manager.js:275:20)
at OptionManager.mergePresets (F:\documentbak\4_18\bak\vue-esri\node_modules\_babel-core@6.26.0@babel-core\lib\transformation\file\options\option-manager.js:264:10)
at OptionManager.mergeOptions (F:\documentbak\4_18\bak\vue-esri\node_modules\_babel-core@6.26.0@babel-core\lib\transformation\file\options\option-manager.js:249:14)
at OptionManager.init (F:\documentbak\4_18\bak\vue-esri\node_modules\_babel-core@6.26.0@babel-core\lib\transformation\file\options\option-manager.js:368:12)
at File.initOptions (F:\documentbak\4_18\bak\vue-esri\node_modules\_babel-core@6.26.0@babel-core\lib\transformation\file\index.js:212:65)
at new File (F:\documentbak\4_18\bak\vue-esri\node_modules\_babel-core@6.26.0@babel-core\lib\transformation\file\index.js:135:24)
at Pipeline.transform (F:\documentbak\4_18\bak\vue-esri\node_modules\_babel-core@6.26.0@babel-core\lib\transformation\pipeline.js:46:16)
at transpile (F:\documentbak\4_18\bak\vue-esri\node_modules\_babel-loader@6.4.1@babel-loader\lib\index.js:46:20)
at Object.module.exports (F:\documentbak\4_18\bak\vue-esri\node_modules\_babel-loader@6.4.1@babel-loader\lib\index.js:163:20)
at index.js:73
PhantomJS 2.1.1 (Windows 7.0.0): Executed 0 of 0 ERROR (0.615 secs / 0 secs)
PhantomJS 2.1.1 (Windows 7.0.0): Executed 0 of 0 ERROR (0 secs / 0 secs)
=============================== Coverage summary ===============================
Statements : 100% ( 0/0 )
Branches : 100% ( 0/0 )
Functions : 100% ( 0/0 )
Lines : 100% ( 0/0 )
================================================================================
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vue-esri@1.0.1 unit: `cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vue-esri@1.0.1 unit script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! D:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2018-04-18T05_52_44_159Z-debug.log
$ npm run lint
> vue-esri@1.0.1 lint F:\documentbak\4_18\bak\vue-esri
> eslint --ext .js,.vue src test/unit/specs test/e2e/specs
F:\documentbak\4_18\bak\vue-esri\src\App.vue
35:39 error Extra semicolon semi
37:13 error Missing space before function parentheses space-before-function-paren
37:15 error Missing space before opening brace space-before-blocks
38:52 error Extra semicolon semi
41:14 error Missing space before value for key 'components' key-spacing
F:\documentbak\4_18\bak\vue-esri\src\components\maps\Draw\Draw.vue
21:14 error Missing space before value for key 'drawType' key-spacing
23:16 error Strings must use singlequote quotes
23:26 error A space is required after ',' comma-spacing
23:27 error Expected space or tab after '//' in comment spaced-comment
29:13 error Missing space before value for key 'items' key-spacing
30:15 error Missing space before value for key 'point' key-spacing
31:20 error Missing space before value for key 'multipoint' key-spacing
32:18 error Missing space before value for key 'polyline' key-spacing
33:17 error Missing space before value for key 'polygon' key-spacing
37:10 error Missing space before function parentheses space-before-function-paren
37:12 error Missing space before opening brace space-before-blocks
38:21 error Extra semicolon semi
39:5 error Expected space(s) after "if" keyword-spacing
39:9 error Redundant double negation no-extra-boolean-cast
39:21 error Missing space before opening brace space-before-blocks
40:7 error 'EventBus' is not defined no-undef
40:29 error A space is required after ',' comma-spacing
40:38 error Missing space before function parentheses space-before-function-paren
40:44 error Missing space before opening brace space-before-blocks
41:26 error Extra semicolon semi
42:9 error Extra semicolon semi
44:21 error Extra semicolon semi
47:23 error Missing space before function parentheses space-before-function-paren
48:23 error Extra semicolon semi
49:31 error Strings must use singlequote quotes
49:56 error A space is required after ',' comma-spacing
49:57 error Strings must use singlequote quotes
52:11 error Extra semicolon semi
55:49 error Extra semicolon semi
55:50 error Expected space or tab after '//' in comment spaced-comment
56:28 error Extra semicolon semi
59:19 error Strings must use singlequote quotes
59:54 error Extra semicolon semi
62:19 error Strings must use singlequote quotes
62:57 error Extra semicolon semi
65:19 error Strings must use singlequote quotes
65:37 error Multiple spaces found before '_this' no-multi-spaces
65:58 error Extra semicolon semi
68:19 error Strings must use singlequote quotes
68:55 error Extra semicolon semi
69:9 error Extra semicolon semi
71:17 error Missing space before function parentheses space-before-function-paren
72:23 error Extra semicolon semi
74:7 error Expected space(s) after "switch" keyword-spacing
74:29 error Missing space before opening brace space-before-blocks
75:14 error Strings must use singlequote quotes
75:22 error Missing space before opening brace space-before-blocks
81:16 error Extra semicolon semi
83:14 error Strings must use singlequote quotes
83:27 error Missing space before opening brace space-before-blocks
89:16 error Extra semicolon semi
91:14 error Strings must use singlequote quotes
91:25 error Missing space before opening brace space-before-blocks
92:13 error Expected indentation of 10 spaces but found 12 indent
96:16 error Extra semicolon semi
98:14 error Strings must use singlequote quotes
98:24 error Missing space before opening brace space-before-blocks
103:16 error Extra semicolon semi
105:17 error Missing space before opening brace space-before-blocks
106:13 error Expected indentation of 10 spaces but found 12 indent
110:16 error Extra semicolon semi
121:19 error Missing space before function parentheses space-before-function-paren
122:23 error Extra semicolon semi
123:20 error Infix operators must be spaced space-infix-ops
123:23 error Strings must use singlequote quotes
124:32 error Extra semicolon semi
128:14 error Missing space before value for key 'components' key-spacing
F:\documentbak\4_18\bak\vue-esri\src\components\maps\Draw\LineSymbol.vue
13:12 error Missing space before value for key 'lPaths' key-spacing
18:12 error Missing space before value for key 'lColor' key-spacing
22:12 error Missing space before value for key 'lWidth' key-spacing
23:20 error A space is required after ',' comma-spacing
31:10 error Missing space before function parentheses space-before-function-paren
31:12 error Missing space before opening brace space-before-blocks
32:21 error Extra semicolon semi
33:21 error Extra semicolon semi
36:23 error Missing space before function parentheses space-before-function-paren
37:23 error Extra semicolon semi
38:31 error Strings must use singlequote quotes
38:45 error A space is required after ',' comma-spacing
38:46 error Strings must use singlequote quotes
40:17 error Strings must use singlequote quotes
43:10 error Extra semicolon semi
46:17 error Strings must use singlequote quotes
49:16 error Strings must use singlequote quotes
50:17 error Strings must use singlequote quotes
51:10 error Extra semicolon semi
53:17 error Strings must use singlequote quotes
53:27 error Infix operators must be spaced space-infix-ops
53:46 error Unexpected trailing comma comma-dangle
54:10 error Extra semicolon semi
60:11 error Extra semicolon semi
62:50 error Extra semicolon semi
63:9 error Extra semicolon semi
68:1 error Too many blank lines at the end of file. Max of 1 allowed no-multiple-empty-lines
F:\documentbak\4_18\bak\vue-esri\src\components\maps\Draw\PictureMarkerSymbol.vue
13:12 error Missing space before value for key 'imgUrl' key-spacing
15:16 error Strings must use singlequote quotes
17:11 error Missing space before value for key 'iLong' key-spacing
22:11 error Missing space before value for key 'iLati' key-spacing
27:12 error Missing space before value for key 'iWidth' key-spacing
28:20 error A space is required after ',' comma-spacing
29:16 error Strings must use singlequote quotes
31:13 error Missing space before value for key 'iHeight' key-spacing
32:20 error A space is required after ',' comma-spacing
33:16 error Strings must use singlequote quotes
35:13 error Missing space before value for key 'xOffset' key-spacing
36:20 error A space is required after ',' comma-spacing
39:13 error Missing space before value for key 'yOffset' key-spacing
40:20 error A space is required after ',' comma-spacing
48:10 error Missing space before function parentheses space-before-function-paren
48:12 error Missing space before opening brace space-before-blocks
49:21 error Extra semicolon semi
50:21 error Extra semicolon semi
53:23 error Missing space before function parentheses space-before-function-paren
54:23 error Extra semicolon semi
55:31 error Strings must use singlequote quotes
55:45 error A space is required after ',' comma-spacing
55:46 error Strings must use singlequote quotes
57:17 error Strings must use singlequote quotes
60:10 error Extra semicolon semi
63:17 error Strings must use singlequote quotes
64:16 error Strings must use singlequote quotes
64:52 error Infix operators must be spaced space-infix-ops
67:19 error Missing space before value for key 'xoffset' key-spacing
68:19 error Missing space before value for key 'yoffset' key-spacing
69:10 error Extra semicolon semi
73:11 error Extra semicolon semi
76:45 error Extra semicolon semi
78:7 error Block must not be padded by blank lines padded-blocks
78:9 error Extra semicolon semi
83:1 error Too many blank lines at the end of file. Max of 1 allowed no-multiple-empty-lines
F:\documentbak\4_18\bak\vue-esri\src\components\maps\Draw\PolygonSymbol.vue
13:12 error Missing space before value for key 'PRings' key-spacing
13:13 error Expected space or tab after '//' in comment spaced-comment
15:21 error Missing space after => arrow-spacing
16:18 error Extra semicolon semi
20:12 error Missing space before value for key 'PColor' key-spacing
20:13 error Expected space or tab after '//' in comment spaced-comment
21:20 error A space is required after ',' comma-spacing
22:21 error Missing space after => arrow-spacing
23:36 error Extra semicolon semi
26:13 error Missing space before value for key 'PlColor' key-spacing
26:14 error Expected space or tab after '//' in comment spaced-comment
27:20 error A space is required after ',' comma-spacing
28:21 error Missing space after => arrow-spacing
29:30 error Extra semicolon semi
32:13 error Missing space before value for key 'PlWidth' key-spacing
32:14 error Expected space or tab after '//' in comment spaced-comment
33:20 error A space is required after ',' comma-spacing
41:10 error Missing space before function parentheses space-before-function-paren
41:12 error Missing space before opening brace space-before-blocks
42:21 error Extra semicolon semi
43:21 error Extra semicolon semi
46:23 error Missing space before function parentheses space-before-function-paren
47:23 error Extra semicolon semi
48:31 error Strings must use singlequote quotes
48:45 error A space is required after ',' comma-spacing
48:46 error Strings must use singlequote quotes
50:17 error Strings must use singlequote quotes
53:10 error Extra semicolon semi
56:17 error Strings must use singlequote quotes
58:18 error Strings must use singlequote quotes
62:18 error Strings must use singlequote quotes
63:19 error Strings must use singlequote quotes
65:10 error Extra semicolon semi
68:17 error Strings must use singlequote quotes
68:26 error Infix operators must be spaced space-infix-ops
68:45 error Unexpected trailing comma comma-dangle
69:10 error Extra semicolon semi
75:11 error Extra semicolon semi
76:49 error Extra semicolon semi
77:9 error Extra semicolon semi
82:1 error Too many blank lines at the end of file. Max of 1 allowed no-multiple-empty-lines
F:\documentbak\4_18\bak\vue-esri\src\components\maps\Views\MapView.vue
20:13 error Missing space before value for key 'evt' key-spacing
20:16 error Missing space before value for key 'x' key-spacing
20:18 error A space is required after ',' comma-spacing
20:21 error Missing space before value for key 'y' key-spacing
21:14 error Missing space before value for key 'view' key-spacing
24:12 error Missing space before function parentheses space-before-function-paren
24:14 error Missing space before opening brace space-before-blocks
25:23 error Extra semicolon semi
26:23 error Extra semicolon semi
31:30 error Extra semicolon semi
36:7 error Expected space or tab after '//' in comment spaced-comment
37:15 error Missing space before function parentheses space-before-function-paren
37:17 error Missing space before opening brace space-before-blocks
42:33 error Extra semicolon semi
45:31 error Extra semicolon semi
50:13 error Extra semicolon semi
53:27 error Extra semicolon semi
57:16 error Missing space before function parentheses space-before-function-paren
58:19 error Infix operators must be spaced space-infix-ops
58:24 error Extra semicolon semi
60:33 error Strings must use singlequote quotes
60:45 error Strings must use singlequote quotes
60:72 error A space is required after ',' comma-spacing
62:22 error Strings must use singlequote quotes
63:13 error Extra semicolon semi
65:24 error Strings must use singlequote quotes
68:40 error A space is required after ',' comma-spacing
69:13 error Extra semicolon semi
70:35 error Extra semicolon semi
71:11 error Extra semicolon semi
74:17 error Missing space before function parentheses space-before-function-paren
75:51 error A space is required after ',' comma-spacing
75:76 error Extra semicolon semi
78:22 error Missing space before function parentheses space-before-function-paren
79:25 error Extra semicolon semi
80:9 error Expected space(s) after "if" keyword-spacing
80:26 error Missing space before opening brace space-before-blocks
82:27 error Missing space before function parentheses space-before-function-paren
82:32 error Missing space before opening brace space-before-blocks
83:42 error Extra semicolon semi
84:15 error Expected space(s) after "if" keyword-spacing
84:32 error Missing space before opening brace space-before-blocks
85:19 error Expected indentation of 14 spaces but found 16 indent
85:40 error Extra semicolon semi
86:19 error Expected indentation of 14 spaces but found 16 indent
86:40 error Extra semicolon semi
88:11 error Expected indentation of 10 spaces but found 8 indent
88:13 error Extra semicolon semi
92:16 error Missing space before value for key 'components' key-spacing
F:\documentbak\4_18\bak\vue-esri\src\components\maps\Views\ScreenView.vue
16:13 error Missing space before value for key 'evt' key-spacing
16:16 error Missing space before value for key 'x' key-spacing
16:18 error A space is required after ',' comma-spacing
16:21 error Missing space before value for key 'y' key-spacing
17:16 error Missing space before value for key 'camera' key-spacing
20:12 error Missing space before function parentheses space-before-function-paren
20:14 error Missing space before opening brace space-before-blocks
21:23 error Extra semicolon semi
22:23 error Extra semicolon semi
26:34 error Expected '===' and instead saw '==' eqeqeq
27:30 error Extra semicolon semi
33:7 error Expected space or tab after '//' in comment spaced-comment
34:15 error Missing space before function parentheses space-before-function-paren
34:17 error Missing space before opening brace space-before-blocks
39:33 error Extra semicolon semi
42:31 error Extra semicolon semi
47:13 error Extra semicolon semi
50:27 error Extra semicolon semi
55:19 error Infix operators must be spaced space-infix-ops
55:24 error Extra semicolon semi
57:33 error Strings must use singlequote quotes
57:45 error Strings must use singlequote quotes
57:67 error A space is required after ',' comma-spacing
57:68 error Strings must use singlequote quotes
57:91 error A space is required after ',' comma-spacing
59:22 error Strings must use singlequote quotes
60:21 error Strings must use singlequote quotes
61:13 error Extra semicolon semi
63:24 error Strings must use singlequote quotes
66:40 error A space is required after ',' comma-spacing
71:13 error Extra semicolon semi
72:35 error Extra semicolon semi
73:11 error Extra semicolon semi
77:51 error A space is required after ',' comma-spacing
77:76 error Extra semicolon semi
80:32 error Missing space before function parentheses space-before-function-paren
81:25 error Extra semicolon semi
83:25 error Missing space before function parentheses space-before-function-paren
83:30 error Missing space before opening brace space-before-blocks
84:48 error Extra semicolon semi
85:13 error Expected space(s) after "if" keyword-spacing
85:30 error Missing space before opening brace space-before-blocks
86:17 error Expected indentation of 12 spaces but found 14 indent
86:38 error Extra semicolon semi
87:17 error Expected indentation of 12 spaces but found 14 indent
87:38 error Extra semicolon semi
89:9 error Expected indentation of 8 spaces but found 6 indent
89:11 error Extra semicolon semi
F:\documentbak\4_18\bak\vue-esri\src\components\maps\Widgets\CameraInfo.vue
16:12 error Missing space before value for key 'camera' key-spacing
19:9 error Unexpected labeled statement no-labels
27:20 error Missing space before function parentheses space-before-function-paren
28:23 error Extra semicolon semi
29:40 error Extra semicolon semi
33:9 error Extra semicolon semi
34:38 error Extra semicolon semi
F:\documentbak\4_18\bak\vue-esri\src\components\maps\Widgets\ScaleBar.vue
13:14 error Missing space before value for key 'position' key-spacing
15:16 error Strings must use singlequote quotes
15:29 error Expected space or tab after '//' in comment spaced-comment
22:10 error Missing space before function parentheses space-before-function-paren
22:12 error Missing space before opening brace space-before-blocks
23:21 error Extra semicolon semi
24:21 error Extra semicolon semi
27:23 error Missing space before function parentheses space-before-function-paren
28:23 error Extra semicolon semi
29:31 error Strings must use singlequote quotes
29:54 error A space is required after ',' comma-spacing
29:55 error Strings must use singlequote quotes
32:17 error Missing space before value for key 'style' key-spacing
32:17 error Strings must use singlequote quotes
32:23 error A space is required after ',' comma-spacing
32:24 error Expected space or tab after '//' in comment spaced-comment
33:16 error Missing space before value for key 'unit' key-spacing
33:16 error Strings must use singlequote quotes
33:24 error Expected space or tab after '//' in comment spaced-comment
34:11 error Extra semicolon semi
38:11 error Extra semicolon semi
39:9 error Extra semicolon semi
F:\documentbak\4_18\bak\vue-esri\src\components\maps\Widgets\SizeSlider.vue
20:12 error Missing space before value for key 'view' key-spacing
23:10 error Missing space before function parentheses space-before-function-paren
23:12 error Missing space before opening brace space-before-blocks
24:21 error Extra semicolon semi
25:21 error Extra semicolon semi
28:23 error Missing space before function parentheses space-before-function-paren
29:11 error '_this' is assigned a value but never used no-unused-vars
29:23 error Extra semicolon semi
30:31 error Strings must use singlequote quotes
30:56 error A space is required after ',' comma-spacing
30:57 error Strings must use singlequote quotes
32:17 error Strings must use singlequote quotes
33:18 error Strings must use singlequote quotes
34:20 error Strings must use singlequote quotes
35:20 error Strings must use singlequote quotes
38:10 error Extra semicolon semi
41:47 error Unexpected trailing comma comma-dangle
42:12 error Strings must use singlequote quotes
42:24 error Extra semicolon semi
44:39 error Extra semicolon semi
45:9 error Extra semicolon semi
F:\documentbak\4_18\bak\vue-esri\src\components\pages\LeftAside.vue
81:5 error Expected indentation of 2 spaces but found 4 indent
82:5 error Expected indentation of 2 spaces but found 4 indent
82:9 error Missing space before function parentheses space-before-function-paren
84:20 error A space is required after ',' comma-spacing
85:29 error A space is required after ',' comma-spacing
87:9 error Expected indentation of 6 spaces but found 8 indent
89:5 error Expected indentation of 2 spaces but found 4 indent
92:5 error Expected indentation of 2 spaces but found 4 indent
93:28 error Missing space before function parentheses space-before-function-paren
94:28 error Extra semicolon semi
96:25 error Missing space before function parentheses space-before-function-paren
96:34 error A space is required after ',' comma-spacing
97:37 error Infix operators must be spaced space-infix-ops
97:42 error Infix operators must be spaced space-infix-ops
97:52 error Extra semicolon semi
100:5 error Expected indentation of 2 spaces but found 4 indent
100:16 error Missing space before value for key 'components' key-spacing
104:11 error Missing space before value for key 'created' key-spacing
104:19 error Missing space before function parentheses space-before-function-paren
104:21 error Missing space before opening brace space-before-blocks
105:20 error Extra semicolon semi
108:21 error Strings must use singlequote quotes
108:33 error Extra semicolon semi
109:35 error Extra semicolon semi
110:40 error Extra semicolon semi
113:29 error Extra semicolon semi
114:9 error Extra semicolon semi
116:3 error Expected indentation of 0 spaces but found 2 indent
F:\documentbak\4_18\bak\vue-esri\src\components\pages\Message.vue
22:6 error Extra semicolon semi
F:\documentbak\4_18\bak\vue-esri\src\components\pages\TopBar.vue
40:18 error Missing space before value for key 'changeType' key-spacing
41:18 error Missing space before value for key 'themeColor' key-spacing
42:16 error Missing space before value for key 'btngroup' key-spacing
44:19 error Missing space before value for key 'content' key-spacing
45:16 error Missing space before value for key 'icon' key-spacing
47:19 error Missing space before value for key 'divided' key-spacing
50:19 error Missing space before value for key 'content' key-spacing
51:16 error Missing space before value for key 'icon' key-spacing
56:19 error Missing space before value for key 'content' key-spacing
57:16 error Missing space before value for key 'icon' key-spacing
66:56 error A space is required after ',' comma-spacing
66:65 error Extra semicolon semi
70:5 error Expected space or tab after '//' in comment spaced-comment
71:18 error Missing space before function parentheses space-before-function-paren
71:27 error Missing space before opening brace space-before-blocks
72:23 error Extra semicolon semi
73:49 error Extra semicolon semi
74:23 error Extra semicolon semi
74:24 error Expected space or tab after '//' in comment spaced-comment
76:16 error Missing space before function parentheses space-before-function-paren
76:22 error Missing space before opening brace space-before-blocks
77:32 error Infix operators must be spaced space-infix-ops
77:38 error Extra semicolon semi
78:23 error Extra semicolon semi
79:37 error A space is required after ',' comma-spacing
79:43 error Extra semicolon semi
81:16 error Missing space before function parentheses space-before-function-paren
81:18 error Missing space before opening brace space-before-blocks
82:33 error Extra semicolon semi
84:39 error A space is required after ',' comma-spacing
84:46 error Extra semicolon semi
85:29 error Strings must use singlequote quotes
85:37 error Extra semicolon semi
87:14 error Missing space before function parentheses space-before-function-paren
87:16 error Missing space before opening brace space-before-blocks
88:31 error Extra semicolon semi
90:39 error A space is required after ',' comma-spacing
90:45 error Extra semicolon semi
91:29 error Strings must use singlequote quotes
91:38 error Extra semicolon semi
93:13 error Missing space before function parentheses space-before-function-paren
93:15 error Missing space before opening brace space-before-blocks
94:23 error Extra semicolon semi
95:39 error A space is required after ',' comma-spacing
95:45 error Extra semicolon semi
97:30 error Extra semicolon semi
99:19 error Missing space before function parentheses space-before-function-paren
99:26 error Missing space before opening brace space-before-blocks
100:23 error Extra semicolon semi
101:37 error A space is required after ',' comma-spacing
101:44 error Extra semicolon semi
102:30 error Infix operators must be spaced space-infix-ops
102:37 error Extra semicolon semi
104:15 error Missing space before function parentheses space-before-function-paren
105:9 error Expected indentation of 6 spaces but found 8 indent
105:62 error Extra semicolon semi
106:9 error Expected indentation of 6 spaces but found 8 indent
106:66 error Extra semicolon semi
107:9 error Expected indentation of 6 spaces but found 8 indent
107:44 error Extra semicolon semi
108:9 error Expected indentation of 6 spaces but found 8 indent
108:25 error Extra semicolon semi
F:\documentbak\4_18\bak\vue-esri\src\components\tools\ToolBar.vue
38:7 error Missing space before function parentheses space-before-function-paren
39:7 error Expected indentation of 4 spaces but found 6 indent
42:8 error Extra semicolon semi
43:5 error Expected indentation of 2 spaces but found 4 indent
45:7 error Expected indentation of 4 spaces but found 6 indent
45:18 error Missing space before function parentheses space-before-function-paren
48:19 error Extra semicolon semi
50:26 error Extra semicolon semi
52:7 error Expected indentation of 4 spaces but found 6 indent
52:19 error Missing space before function parentheses space-before-function-paren
53:36 error Extra semicolon semi
55:7 error Expected indentation of 4 spaces but found 6 indent
55:20 error Missing space before function parentheses space-before-function-paren
56:26 error Extra semicolon semi
58:7 error Expected indentation of 4 spaces but found 6 indent
58:19 error Missing space before function parentheses space-before-function-paren
59:115 error Extra semicolon semi
61:7 error Expected indentation of 4 spaces but found 6 indent
61:19 error Missing space before function parentheses space-before-function-paren
62:36 error Unexpected space(s) after '${' template-curly-spacing
62:49 error Unexpected space(s) before '}' template-curly-spacing
62:53 error Extra semicolon semi
64:7 error Expected indentation of 4 spaces but found 6 indent
64:11 error Missing space before function parentheses space-before-function-paren
69:11 error Extra semicolon semi
72:7 error Expected indentation of 4 spaces but found 6 indent
72:13 error Missing space before function parentheses space-before-function-paren
73:38 error Extra semicolon semi
81:11 error Extra semicolon semi
83:7 error Expected indentation of 4 spaces but found 6 indent
83:14 error Missing space before function parentheses space-before-function-paren
89:33 error Unexpected space(s) after '${' template-curly-spacing
89:43 error Unexpected space(s) before '}' template-curly-spacing
90:15 error Extra semicolon semi
92:11 error Extra semicolon semi
94:5 error Expected indentation of 2 spaces but found 4 indent
F:\documentbak\4_18\bak\vue-esri\src\components\tools\ToolBox.vue
13:7 error Missing space before function parentheses space-before-function-paren
14:7 error Expected indentation of 4 spaces but found 6 indent
16:14 error Missing space before value for key 'view' key-spacing
17:17 error Missing space before value for key 'widgets' key-spacing
18:8 error Extra semicolon semi
20:10 error Missing space before function parentheses space-before-function-paren
20:12 error Missing space before opening brace space-before-blocks
21:21 error Extra semicolon semi
22:5 error Expected space(s) after "if" keyword-spacing
22:9 error Redundant double negation no-extra-boolean-cast
22:21 error Missing space before opening brace space-before-blocks
23:7 error 'EventBus' is not defined no-undef
23:29 error A space is required after ',' comma-spacing
23:38 error Missing space before function parentheses space-before-function-paren
23:44 error Missing space before opening brace space-before-blocks
24:26 error Extra semicolon semi
25:9 error Extra semicolon semi
27:24 error Extra semicolon semi
30:7 error Expected indentation of 4 spaces but found 6 indent
31:11 error Expected indentation of 8 spaces but found 10 indent
31:15 error Identifier 't_widgets' is not in camel case camelcase
31:39 error Extra semicolon semi
32:11 error Expected indentation of 8 spaces but found 10 indent
33:15 error Expected indentation of 12 spaces but found 14 indent
34:13 error Extra semicolon semi
38:7 error Expected indentation of 4 spaces but found 6 indent
38:18 error Missing space before function parentheses space-before-function-paren
38:20 error Missing space before opening brace space-before-blocks
39:25 error Extra semicolon semi
42:25 error Strings must use singlequote quotes
42:38 error Extra semicolon semi
43:39 error Extra semicolon semi
44:48 error Extra semicolon semi
47:33 error Extra semicolon semi
48:13 error Extra semicolon semi
50:7 error Expected indentation of 4 spaces but found 6 indent
50:11 error Missing space before function parentheses space-before-function-paren
55:11 error Extra semicolon semi
F:\documentbak\4_18\bak\vue-esri\src\layouts\HeaderAsideFooterResponsiveLayout\Layout.vue
35:1 error More than 1 blank line not allowed no-multiple-empty-lines
45:41 error Extra semicolon semi
48:11 error Missing space before value for key 'methods' key-spacing
50:14 error Missing space before value for key 'components' key-spacing
F:\documentbak\4_18\bak\vue-esri\src\layouts\HeaderFooterResponsiveLayout\Layout.vue
27:41 error Extra semicolon semi
30:11 error Missing space before value for key 'methods' key-spacing
32:14 error Missing space before value for key 'components' key-spacing
F:\documentbak\4_18\bak\vue-esri\src\main.js
24:1 error Do not use 'new' for side effects no-new
F:\documentbak\4_18\bak\vue-esri\src\pages\Default.vue
16:14 error Missing space before value for key 'components' key-spacing
F:\documentbak\4_18\bak\vue-esri\src\pages\Feature.vue
25:11 error Missing space before value for key 'created' key-spacing
25:19 error Missing space before function parentheses space-before-function-paren
25:21 error Missing space before opening brace space-before-blocks
26:20 error Extra semicolon semi
29:21 error Strings must use singlequote quotes
29:36 error Extra semicolon semi
30:35 error Extra semicolon semi
31:41 error Extra semicolon semi
34:29 error Extra semicolon semi
35:9 error Extra semicolon semi
F:\documentbak\4_18\bak\vue-esri\src\pages\Hello.vue
18:11 error Missing space before value for key 'msg' key-spacing
18:11 error Strings must use singlequote quotes
F:\documentbak\4_18\bak\vue-esri\src\pages\Login.vue
71:28 error Extra semicolon semi
76:21 error Extra semicolon semi
79:38 error Extra semicolon semi
80:14 error Block must not be padded by blank lines padded-blocks
82:50 error Infix operators must be spaced space-infix-ops
82:84 error Extra semicolon semi
85:45 error Extra semicolon semi
87:19 error Extra semicolon semi
89:6 error Extra semicolon semi
93:37 error Extra semicolon semi
96:57 error Extra semicolon semi
97:10 error Expected space(s) before "else" keyword-spacing
97:32 error Missing space before opening brace space-before-blocks
98:57 error Infix operators must be spaced space-infix-ops
98:92 error Extra semicolon semi
100:44 error Extra semicolon semi
103:19 error Extra semicolon semi
105:6 error Extra semicolon semi
108:7 error Expected space(s) after "if" keyword-spacing
108:22 error Missing space before opening brace space-before-blocks
110:43 error Extra semicolon semi
112:44 error Extra semicolon semi
114:21 error Extra semicolon semi
116:8 error Expected space(s) before "else" keyword-spacing
116:8 error Expected space(s) after "else" keyword-spacing
117:19 error Extra semicolon semi
120:5 error Block must not be padded by blank lines padded-blocks
120:6 error Extra semicolon semi
122:16 error Missing space before value for key 'ruleForm' key-spacing
139:6 error Extra semicolon semi
143:23 error Extra semicolon semi
146:32 error Extra semicolon semi
147:41 error A space is required after ',' comma-spacing
147:93 error Extra semicolon semi
148:42 error A space is required after ',' comma-spacing
148:94 error Extra semicolon semi
149:43 error A space is required after ',' comma-spacing
149:50 error Extra semicolon semi
150:44 error A space is required after ',' comma-spacing
150:51 error Extra semicolon semi
153:42 error Extra semicolon semi
155:9 error Extra semicolon semi
157:5 error Block must not be padded by blank lines padded-blocks
159:23 error Extra semicolon semi
162:32 error Extra semicolon semi
163:41 error A space is required after ',' comma-spacing
163:93 error Extra semicolon semi
164:42 error A space is required after ',' comma-spacing
164:94 error Extra semicolon semi
165:43 error A space is required after ',' comma-spacing
165:50 error Extra semicolon semi
166:44 error A space is required after ',' comma-spacing
166:51 error Extra semicolon semi
169:54 error Extra semicolon semi
171:9 error Extra semicolon semi
173:5 error Block must not be padded by blank lines padded-blocks
175:8 error Expected indentation of 6 spaces but found 7 indent
175:42 error Extra semicolon semi
176:8 error Expected indentation of 6 spaces but found 7 indent
176:25 error Extra semicolon semi
179:41 error Extra semicolon semi
180:25 error Extra semicolon semi
182:15 error Missing space before function parentheses space-before-function-paren
183:9 error Expected indentation of 6 spaces but found 8 indent
183:58 error Extra semicolon semi
184:9 error Expected indentation of 6 spaces but found 8 indent
184:57 error Extra semicolon semi
185:9 error Expected indentation of 6 spaces but found 8 indent
185:39 error Extra semicolon semi
186:9 error Expected indentation of 6 spaces but found 8 indent
186:23 error Extra semicolon semi
188:15 error Missing space before function parentheses space-before-function-paren
189:9 error Expected indentation of 6 spaces but found 8 indent
189:62 error Extra semicolon semi
190:9 error Expected indentation of 6 spaces but found 8 indent
190:66 error Extra semicolon semi
191:9 error Expected indentation of 6 spaces but found 8 indent
191:44 error Extra semicolon semi
192:9 error Expected indentation of 6 spaces but found 8 indent
192:25 error Extra semicolon semi
194:12 error Missing space before function parentheses space-before-function-paren
194:17 error Missing space before opening brace space-before-blocks
199:18 error Missing space before value for key 'duration' key-spacing
200:9 error Extra semicolon semi
202:12 error Missing space before function parentheses space-before-function-paren
202:17 error Missing space before opening brace space-before-blocks
207:9 error Extra semicolon semi
211:2 error Extra semicolon semi
F:\documentbak\4_18\bak\vue-esri\src\pages\Manage.vue
16:14 error Missing space before value for key 'components' key-spacing
✖ 598 problems (598 errors, 0 warnings)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vue-esri@1.0.1 lint: `eslint --ext .js,.vue src test/unit/specs test/e2e/specs`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vue-esri@1.0.1 lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! D:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2018-04-18T06_00_50_258Z-debug.log
注意本地需要有JDK
环境,初始启动环境的时间会有点长,需要耐心等待
$ npm run e2e
> vue-esri@1.0.1 e2e F:\documentbak\4_18\bak\vue-esri
> node test/e2e/runner.js
> Starting dev server...
(node:11188) DeprecationWarning: loaderUtils.parseQuery() received a non-string value which can be problematic, see https://github.com/webpack/loader-utils/issues/56
parseQuery() will be replaced with getOptions() in the next major version of loader-utils.
Starting to optimize CSS...
Processing static/css/app.c99a364e7ec43738abdd8f68c78d2bec.css...
Processed static/css/app.c99a364e7ec43738abdd8f68c78d2bec.css, before: 263302, after: 237888, ratio: 90.35%
> Listening at http://localhost:8081
Starting selenium server... started - PID: 11160
[Test] Test Suite
=====================
Running: default e2e tests
√ Element <#app> was visible after 266 milliseconds.
× Testing if element <.hello> is present. - expected "present" but got: "not present"
at Object.defaultE2eTests [as default e2e tests] (F:/documentbak/4_18/bak/vue-esri/test/e2e/specs/test.js:14:15)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
FAILED: 1 assertions failed and 1 passed (27.892s)
_________________________________________________
TEST FAILURE: 1 assertions failed, 1 passed. (28.287s)
× test
- default e2e tests (27.892s)
Testing if element <.hello> is present. - expected "present" but got: "not present"
at Object.defaultE2eTests [as default e2e tests] (F:/documentbak/4_18/bak/vue-esri/test/e2e/specs/test.js:14:15)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vue-esri@1.0.1 e2e: `node test/e2e/runner.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vue-esri@1.0.1 e2e script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! D:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2018-04-18T06_05_58_154Z-debug.log
test/e2e/specs/test.js
配置修改前
// For authoring Nightwatch tests, see
// http://nightwatchjs.org/guide#usage
module.exports = {
'default e2e tests': function (browser) {
// automatically uses dev Server port from /config.index.js
// default: http://localhost:8080
// see nightwatch.conf.js
const devServer = browser.globals.devServerURL
browser
.url(devServer)
.waitForElementVisible('#app', 5000)
.assert.elementPresent('.hello')
.assert.containsText('h1', 'Welcome to Your Vue.js App')
.assert.elementCount('img', 1)
.end()
}
}
修改后
// For authoring Nightwatch tests, see
// http://nightwatchjs.org/guide#usage
module.exports = {
'default e2e tests': function (browser) {
// automatically uses dev Server port from /config.index.js
// default: http://localhost:8080
// see nightwatch.conf.js
const devServer = browser.globals.devServerURL
browser
.url(devServer)
.waitForElementVisible('#app', 5000)
.assert.elementCount('login', 1)
.assert.elementCount('el-container', 1)
.assert.elementCount('top-bar', 1)
.assert.elementCount('manage', 1)
.assert.elementCount('default', 1)
.end()
}
}
$ npm run e2e
> vue-esri@1.0.1 e2e F:\documentbak\4_18\bak\vue-esri
> node test/e2e/runner.js
> Starting dev server...
Starting to optimize CSS...
Processing static/css/app.c99a364e7ec43738abdd8f68c78d2bec.css...
Processed static/css/app.c99a364e7ec43738abdd8f68c78d2bec.css, before: 263302, after: 237888, ratio: 90.35%
> Listening at http://localhost:8081
Starting selenium server... started - PID: 11124
[Test] Test Suite
=====================
Running: default e2e tests
√ Element <#app> was visible after 268 milliseconds.
× Testing if element <login> has count: 1 - expected "1" but got: "0"
at Object.defaultE2eTests [as default e2e tests] (F:/documentbak/4_18/bak/vue-esri/test/e2e/specs/test.js:15:15)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
FAILED: 1 assertions failed and 1 passed (28.615s)
_________________________________________________
TEST FAILURE: 1 assertions failed, 1 passed. (28.786s)
× test
- default e2e tests (28.615s)
Testing if element <login> has count: 1 - expected "1" but got: "0"
at Object.defaultE2eTests [as default e2e tests] (F:/documentbak/4_18/bak/vue-esri/test/e2e/specs/test.js:15:15)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vue-esri@1.0.1 e2e: `node test/e2e/runner.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vue-esri@1.0.1 e2e script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! D:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2018-04-18T06_27_31_873Z-debug.log
站在程序员的角度测试
unit测试是把代码看成是一个个的组件。从而实现每一个组件的单独测试,测试内容主要是组件内每一个函数的返回结果是不是和期望值一样。
const compare = (a,b) => a>b?a:b
// 对这个函数进行测试
expect(compare(1,2)).to.equal(2) //ok
expect(compare(2,1)).to.equal(1) //ok
// 测试完成
而代码覆盖率是指代码中每一个函数的每一中情况的测试情况,上述测试的代码覆盖率是100%
const compare = (a,b) => a>b?a:b
// 对这个函数进行测试
expect(compare(2,1)).to.equal(1) //ok
// 测试完成
这样代码覆盖率是50%,因为else情况没有测试到
站在用户角度的测试
e2e测试是把我们的程序堪称是一个黑盒子,我不懂你内部是怎么实现的,我只负责打开浏览器,把测试内容在页面上输入一遍,看是不是我想要得到的结果。
两者的存在都是很有意义的。 unit测试是程序员写好自己的逻辑后可以很容易的测试自己的逻辑返回的是不是都正确。 e2e代码是测试所有的需求是不是都可以正确的完成,而且最终要的是在代码重构,js改动很多之后,需要对需求进行测试的时候测试代码是不需要改变的,你也不用担心在重构后不能达到客户的需求。
https://www.cnblogs.com/cqhaibin/p/6581350.html
此篇文章是续webpack多入口文件、热更新等体验,主要说明单元测试与e2e测试的基本配置以及相关应用。
实现单元测试框架的搭建、es6语法的应用、以及测试覆盖率的引入。
由于babel-plugin-istanbul
是babel
的一个插件,所以需要修改.babelrc文
件,代码如下:
{
"presets": [
["env", { "modules": false }],
"stage-2"
],
"plugins": ["transform-runtime"],
"comments": false,
"env": {
"test": {
"presets": ["env", "stage-2"],
"plugins": [ "istanbul" ]
}
}
}
运行命令 .\node_modules\.bin\karma start .\test\karma.conf.js
文件路径 \unit\karma.conf.js
karma
命令为私有安装,karma
配置文件指定在test文件夹下。
// This is a karma config file. For more details see
// http://karma-runner.github.io/0.13/config/configuration-file.html
// we are also using it with karma-webpack
// https://github.com/webpack/karma-webpack
var webpackConfig = require('../../build/webpack.test.conf')
module.exports = function(config) {
config.set({
// 基路径:表示karma从那个位置开始找文件
basePath: '',
// 框架
frameworks: ['mocha', 'sinon-chai', 'phantomjs-shim'],
// 测试的入口文件
files: ['.index.js'],
// 排除的文件,可以是正则
exclude: [
],
// 对指定文件的preprocess(预处理)
preprocessors: {
'../test/unit/index.js': ['webpack', 'sourcemap'],
'../src/**/*.js': ['webpack','sourcemap', 'coverage', 'coverage'] //表示那些代码需要生成测试覆盖率报表
},
// 结果报表
reporters: ['progress'],
// 服务器端口
port: 9876,
// 报表中是否有颜色区分
colors: true,
// 输出的日志级别
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// 文件变化是否自动刷新
autoWatch: true,
// 测试的测试器环境
browsers: ['PhantomJS'],
// 是否依附浏览器运行
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
// 并发个数,同时支持在多少个浏览器运行
// how many browser should be started simultaneous
concurrency: Infinity,
//webpack配置
webpack: webpackConfig,
webpackMiddleware: {
noInfo: true
},
//代码覆盖率配置节点
coverageReporter:{
dir: './converage',
reporters:[
{ type: 'lcov', subdir: '.' },
{type: 'text-summary'}
],
}
})
}
import {init} from '../../src/ma'
import data from '../mocks/demo'
describe('demo_spec', function(){
it('body',() => {
init();
let button = document.querySelector('.btn');
button.textContent = data.btnName;
expect(button.textContent).toEqual(data.btnName);
})
});
src/ma:会向dom插件一个button标签
import Mock from 'mockjs';
var template = {
'title': 'Demo01',
'btnName|1-3': '*'
}
export default Mock.mock(template);
mocks/demo:用mockjs模拟的一些数据
npm run unit
就可以进行单元测试了 "scripts": {
"unit": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run"
},
selenium-server
由于浏览器同源策略(域名、协议、端口相同才是同源,如不明白可以baidu)的限制,selenimue
就以代理的方式进行目标站点的测试(也就是测试环境跑的浏览器连接是selenium-server
产生的代理服务器),selenium-server
代理服务器=selenium核心Js
+ 测试目标站点(proxy)
。
文件路径test/e2e/nightwatch.conf.js
require('babel-register')
var config = require('../../config')
// http://nightwatchjs.org/gettingstarted#settings-file
module.exports = {
src_folders: ['test/e2e/specs'],
output_folder: 'test/e2e/reports',
custom_assertions_path: ['test/e2e/custom-assertions'],
selenium: {
start_process: true,
server_path: require('selenium-server').path,
host: '127.0.0.1',
port: 4444,
cli_args: {
'webdriver.chrome.driver': require('chromedriver').path
}
},
test_settings: {
default: {
selenium_port: 4444,
selenium_host: 'localhost',
silent: true,
globals: {
devServerURL: 'http://localhost:' + (process.env.PORT || config.dev.port)
}
},
chrome: {
desiredCapabilities: {
browserName: 'chrome',
javascriptEnabled: true,
acceptSslCerts: true
}
},
firefox: {
desiredCapabilities: {
browserName: 'firefox',
javascriptEnabled: true,
acceptSslCerts: true
}
}
}
}
文件路径test/e2e/custom-assertions/elementCount.js
// A custom Nightwatch assertion.
// the name of the method is the filename.
// can be used in tests like this:
//
// browser.assert.elementCount(selector, count)
//
// for how to write custom assertions see
// http://nightwatchjs.org/guide#writing-custom-assertions
exports.assertion = function (selector, count) {
this.message = 'Testing if element <' + selector + '> has count: ' + count
this.expected = count
this.pass = function (val) {
return val === this.expected
}
this.value = function (res) {
return res.value
}
this.command = function (cb) {
var self = this
return this.api.execute(function (selector) {
return document.querySelectorAll(selector).length
}, [selector], function (res) {
cb.call(self, res)
})
}
}
文件路径test/e2e/specs/test.js
// For authoring Nightwatch tests, see
// http://nightwatchjs.org/guide#usage
module.exports = {
'default e2e tests': function (browser) {
// automatically uses dev Server port from /config.index.js
// default: http://localhost:8080
// see nightwatch.conf.js
const devServer = browser.globals.devServerURL
browser
.url(devServer)
.waitForElementVisible('#app', 5000)
.assert.elementPresent('.hello')
.assert.containsText('h1', 'Welcome to Your Vue.js App')
.assert.elementCount('img', 1)
.end()
}
}
runner.js
// 1. start the dev server using production config
process.env.NODE_ENV = 'testing'
var server = require('../../build/dev-server.js')
server.ready.then(() => {
// 2. run the nightwatch test suite against it
// to run in additional browsers:
// 1. add an entry in test/e2e/nightwatch.conf.json under "test_settings"
// 2. add it to the --env flag below
// or override the environment flag, for example: `npm run e2e -- --env chrome,firefox`
// For more information on Nightwatch's config file, see
// http://nightwatchjs.org/guide#settings-file
var opts = process.argv.slice(2)
if (opts.indexOf('--config') === -1) {
opts = opts.concat(['--config', 'test/e2e/nightwatch.conf.js'])
}
if (opts.indexOf('--env') === -1) {
opts = opts.concat(['--env', 'chrome'])
}
var spawn = require('cross-spawn')
var runner = spawn('./node_modules/.bin/nightwatch', opts, { stdio: 'inherit' })
runner.on('exit', function (code) {
server.close()
process.exit(code)
})
runner.on('error', function (err) {
server.close()
throw err
})
})
npm run e2e
就可以进行单元测试了 "scripts": {
"e2e": "node test/e2e/runner.js"
},
重新修改test/e2e/specs/test.js配置
// For authoring Nightwatch tests, see
// http://nightwatchjs.org/guide#usage
module.exports = {
'default e2e tests': function (browser) {
// automatically uses dev Server port from /config.index.js
// default: http://localhost:8080
// see nightwatch.conf.js
const devServer = browser.globals.devServerURL
browser
.url(devServer)
.waitForElementVisible('#app', 5000)
// .assert.elementPresent('.Login')
.assert.elementCount('div.loginBox', 1)
.assert.elementCount('form.el-form', 1)
.end()
}
}
$ npm run e2e
> vue-esri@1.0.1 e2e F:\documentbak\4_18\bak\vue-esri
> node test/e2e/runner.js
> Starting dev server...
Starting to optimize CSS...
Processing static/css/app.c99a364e7ec43738abdd8f68c78d2bec.css...
Processed static/css/app.c99a364e7ec43738abdd8f68c78d2bec.css, before: 263302, after: 237888, ratio: 90.35%
> Listening at http://localhost:8081
Starting selenium server... started - PID: 13268
[Test] Test Suite
=====================
Running: default e2e tests
√ Element <#app> was visible after 186 milliseconds.
√ Testing if element <div.loginBox> has count: 1
√ Testing if element <form.el-form> has count: 1
OK. 3 assertions passed. (23.781s)
好歹完整通过了一个测试,日常捂脸.jpg
编写测试脚本nightwatch 在测试用例编写的时候还是很舒服的。我们在test/e2e/specs文件夹下建立对页面的测试。
module.exports = {
'default e2e tests': function (browser) {
const devServer = browser.globals.devServerURL
browser
.url(devServer)
... // 你的测试代码
.end()
}
}
.url('http://www.google.com') // 打开地址
.waitForElementVisible('body', 1000) // 等待界面显示
.assert.title('Google') // 断言title为Google
.assert.visible('input[type=text]') // 断言输入框显示
.setValue('input[type=text]', 'rembrandt van rijn') // 设置输入框的值
.waitForElementVisible('button[name=btnG]', 1000) // 等待按钮显示
.click('button[name=btnG]') // 点击按钮
.pause(1000) // 暂停等待请求
.assert.containsText('ol#rso li:first-child', 'Rembrandt - Wikipedia')
// 断言包含字符串
.end();
根据api重新修改test/e2e/specs/test.js配置,整个复杂点的
// For authoring Nightwatch tests, see
// http://nightwatchjs.org/guide#usage
module.exports = {
'default e2e tests': function (browser) {
// automatically uses dev Server port from /config.index.js
// default: http://localhost:8080
// see nightwatch.conf.js
const devServer = browser.globals.devServerURL
browser
.url(devServer)
.waitForElementVisible('#app', 5000)
// .assert.elementPresent('.Login')
.assert.elementCount('div.loginBox', 1)
.assert.elementCount('form.el-form', 1)
.end()
}
}
test/unit/karma.conf.js
修改前
// This is a karma config file. For more details see
// http://karma-runner.github.io/0.13/config/configuration-file.html
// we are also using it with karma-webpack
// https://github.com/webpack/karma-webpack
var webpackConfig = require('../../build/webpack.test.conf')
module.exports = function (config) {
config.set({
// to run in additional browsers:
// 1. install corresponding karma launcher
// http://karma-runner.github.io/0.13/config/browsers.html
// 2. add it to the `browsers` array below.
browsers: ['PhantomJS'],
frameworks: ['mocha', 'sinon-chai', 'phantomjs-shim'],
reporters: ['spec', 'coverage'],
files: ['./index.js'],
preprocessors: {
'./index.js': ['webpack', 'sourcemap']
},
webpack: webpackConfig,
webpackMiddleware: {
noInfo: true
},
coverageReporter: {
dir: './coverage',
reporters: [
{ type: 'lcov', subdir: '.' },
{ type: 'text-summary' }
]
}
})
}
修改后
// This is a karma config file. For more details see
// http://karma-runner.github.io/0.13/config/configuration-file.html
// we are also using it with karma-webpack
// https://github.com/webpack/karma-webpack
var webpackConfig = require('../../build/webpack.test.conf')
module.exports = function (config) {
config.set({
// to run in additional browsers:
// 1. install corresponding karma launcher
// http://karma-runner.github.io/0.13/config/browsers.html
// 2. add it to the `browsers` array below.
// 测试的测试器环境
browsers: ['PhantomJS'],
// 框架
frameworks: ['mocha', 'sinon-chai', 'phantomjs-shim'],
// 结果报表
reporters: ['progress', 'spec', 'coverage'],
// 测试的入口文件
files: ['./index.js'],
// 对指定文件的preprocess(预处理)
preprocessors: {
'./index.js': ['webpack', 'sourcemap'],
'../src/**/*.js': ['webpack', 'sourcemap', 'coverage'] // 表示那些代码需要生成测试覆盖率报表
},
// webpack配置
webpack: webpackConfig,
webpackMiddleware: {
noInfo: true
},
// 代码覆盖率配置节点
coverageReporter: {
dir: './coverage',
reporters: [
{ type: 'lcov', subdir: '.' },
{ type: 'text-summary' }
]
},
// 报表中是否有颜色区分
colors: true,
// 输出的日志级别
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// 文件变化是否自动刷新
autoWatch: true,
// 是否依附浏览器运行
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
// 并发个数,同时支持在多少个浏览器运行
// how many browser should be started simultaneous
concurrency: Infinity
})
}
build/webpack.base.conf.js
修改前
entry: {
app: ["babel-polyfill", "./src/main.js"]
},
修改后
entry: {
'babel-polyfill': 'babel-polyfill',
app: './src/main.js'
},
$ npm run unit
> vue-esri@1.0.1 unit F:\documentbak\4_18\bak\vue-esri
> cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run
18 04 2018 17:33:13.341:INFO [karma]: Karma v1.7.1 server started at http://0.0.0.0:9876/
18 04 2018 17:33:13.350:INFO [launcher]: Launching browser PhantomJS with unlimited concurrency
18 04 2018 17:33:13.369:INFO [launcher]: Starting browser PhantomJS
18 04 2018 17:33:17.542:INFO [PhantomJS 2.1.1 (Windows 7.0.0)]: Connected on socket us3kbciLXcni6zU0AAAA with id 12860677
PhantomJS 2.1.1 (Windows 7.0.0) ERROR
Error: [vuex] vuex requires a Promise polyfill in this browser.
at webpack:///~/_vuex@2.5.0@vuex/dist/vuex.esm.js:97:0 <- index.js:57484
PhantomJS 2.1.1 (Windows 7.0.0) ERROR
Error: [vuex] vuex requires a Promise polyfill in this browser.
at webpack:///~/_vuex@2.5.0@vuex/dist/vuex.esm.js:97:0 <- index.js:57484
PhantomJS 2.1.1 (Windows 7.0.0): Executed 0 of 0 ERROR (0.94 secs / 0 secs)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vue-esri@1.0.1 unit: `cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vue-esri@1.0.1 unit script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! D:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2018-04-18T09_33_18_720Z-debug.log
test/unit/karma.conf.js
修改前
// This is a karma config file. For more details see
// http://karma-runner.github.io/0.13/config/configuration-file.html
// we are also using it with karma-webpack
// https://github.com/webpack/karma-webpack
var webpackConfig = require('../../build/webpack.test.conf')
module.exports = function (config) {
config.set({
// to run in additional browsers:
// 1. install corresponding karma launcher
// http://karma-runner.github.io/0.13/config/browsers.html
// 2. add it to the `browsers` array below.
// 测试的测试器环境
browsers: ['PhantomJS'],
// 框架
frameworks: ['mocha', 'sinon-chai', 'phantomjs-shim'],
// 结果报表
reporters: ['progress', 'spec', 'coverage'],
// 测试的入口文件
files: ['./index.js'],
// 对指定文件的preprocess(预处理)
preprocessors: {
'./index.js': ['webpack', 'sourcemap'],
'../src/**/*.js': ['webpack', 'sourcemap', 'coverage'] // 表示那些代码需要生成测试覆盖率报表
},
// webpack配置
webpack: webpackConfig,
webpackMiddleware: {
noInfo: true
},
// 代码覆盖率配置节点
coverageReporter: {
dir: './coverage',
reporters: [
{ type: 'lcov', subdir: '.' },
{ type: 'text-summary' }
]
},
// 报表中是否有颜色区分
colors: true,
// 输出的日志级别
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// 文件变化是否自动刷新
autoWatch: true,
// 是否依附浏览器运行
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
// 并发个数,同时支持在多少个浏览器运行
// how many browser should be started simultaneous
concurrency: Infinity
})
}
修改后
// This is a karma config file. For more details see
// http://karma-runner.github.io/0.13/config/configuration-file.html
// we are also using it with karma-webpack
// https://github.com/webpack/karma-webpack
var webpackConfig = require('../../build/webpack.test.conf')
module.exports = function (config) {
config.set({
// to run in additional browsers:
// 1. install corresponding karma launcher
// http://karma-runner.github.io/0.13/config/browsers.html
// 2. add it to the `browsers` array below.
// 测试的测试器环境
browsers: ['PhantomJS'],
// 框架
frameworks: ['mocha', 'sinon-chai', 'phantomjs-shim'],
// 结果报表
reporters: ['progress', 'spec', 'coverage'],
// 测试的入口文件
files: [
'../../node_modules/babel-polyfill/dist/polyfill.js',
'./index.js'
],
// 对指定文件的preprocess(预处理)
preprocessors: {
'./index.js': ['webpack', 'sourcemap'],
'../src/**/*.js': ['webpack', 'sourcemap', 'coverage'] // 表示那些代码需要生成测试覆盖率报表
},
// webpack配置
webpack: webpackConfig,
webpackMiddleware: {
noInfo: true
},
// 代码覆盖率配置节点
coverageReporter: {
dir: './coverage',
reporters: [
{ type: 'lcov', subdir: '.' },
{ type: 'text-summary' }
]
},
// 报表中是否有颜色区分
colors: true,
// 输出的日志级别
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// 文件变化是否自动刷新
autoWatch: true,
// 是否依附浏览器运行
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
// 并发个数,同时支持在多少个浏览器运行
// how many browser should be started simultaneous
concurrency: Infinity
})
}
$ npm run unit
> vue-esri@1.0.1 unit F:\documentbak\4_18\bak\vue-esri
> cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run
18 04 2018 19:20:05.340:INFO [karma]: Karma v1.7.1 server started at http://0.0.0.0:9876/
18 04 2018 19:20:05.349:INFO [launcher]: Launching browser PhantomJS with unlimited concurrency
18 04 2018 19:20:05.368:INFO [launcher]: Starting browser PhantomJS
18 04 2018 19:20:09.570:INFO [PhantomJS 2.1.1 (Windows 7.0.0)]: Connected on socket vE_a3_T9ZLusSa4mAAAA with id 83186055
ERROR: '[Vue warn]: Error in render: "TypeError: undefined is not an object (evaluating '_vm.$route.query')"
(found in <Root>)'
PhantomJS 2.1.1 (Windows 7.0.0): Executed 0 of 1 SUCCESS (0 secs / 0 secs)
ERROR LOG: '[Vue warn]: Error in render: "TypeError: undefined is not an object (evaluating '_vm.$route.query')"
ERROR: TypeError{stack: 'render@http://localhost:9876/base/index.js?ee5570e025c04344e0eea4f3a9a15f3d7ea0a523:53414:46
_render@http://localhost:9876/base/index.js?ee5570e025c04344e0eea4f3a9a15f3d7ea0a523:11422:26
updateComponent@http://localhost:9876/base/index.js?ee5570e025c04344e0eea4f3a9a15f3d7ea0a523:9666:28
get@http://localhost:9876/base/index.js?ee5570e025c04344e0eea4f3a9a15f3d7ea0a523:10020:29
Watcher@http://localhost:9876/base/index.js?ee5570e025c04344e0eea4f3a9a15f3d7ea0a523:10009:15
mountComponent@http://localhost:9876/base/index.js?ee5570e025c04344e0eea4f3a9a15f3d7ea0a523:9673:14
$mount@http://localhost:9876/base/index.js?ee5570e025c04344e0eea4f3a9a15f3d7ea0a523:15418:24
$mount@http://localhost:9876/base/index.js?ee5570e025c04344e0eea4f3a9a15f3d7ea0a523:17817:20
http://localhost:9876/base/index.js?ee5570e025c04344e0eea4f3a9a15f3d7ea0a523:44003:38
callFn@http://localhost:9876/absoluteF:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js?8bf1d1adf34e719cca6e8f6915b9cd6eabf83d6b:4481:25
run@http://localhost:9876/absoluteF:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js?8bf1d1adf34e719cca6e8f6915b9cd6eabf83d6b:4473:13
runTest@http://localhost:9876/absoluteF:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js?8bf1d1adf34e719cca6e8f6915b9cd6eabf83d6b:4969:13
http://localhost:9876/absoluteF:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js?8bf1d1adf34e719cca6e8f6915b9cd6eabf83d6b:5075:19
next@http://localhost:9876/absoluteF:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js?8bf1d1adf34e719cca6e8f6915b9cd6eabf83d6b:4887:16
http://localhost:9876/absoluteF:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js?8bf1d1adf34e719cca6e8f6915b9cd6eabf83d6b:4897:11
next@http://localhost:9876/absoluteF:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js?8bf1d1adf34e719cca6e8f6915b9cd6eabf83d6b:4821:16
http://localhost:9876/absoluteF:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js?8bf1d1adf34e719cca6e8f6915b9cd6eabf83d6b:4865:9
timeslice@http://localhost:9876/absoluteF:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js?8bf1d1adf34e719cca6e8f6915b9cd6eabf83d6b:82:27', line: 53414, sourceURL: 'http://localhost:9876/base/index.js?ee5570e025c04344e0eea4f3a9a15f3d7ea0a523'}
PhantomJS 2.1.1 (Windows 7.0.0): Executed 0 of 1 SUCCESS (0 secs / 0 secs)
ERROR LOG: TypeError{stack: 'render@http://localhost:9876/base/index.js?ee5570e025c04344e0eea4f3a9a15f3d7ea0a523:53414:46
_render@http://localhost:9876/base/index.js?ee5570e025c04344e0eea4f3a9a15f3d7ea0a523:11422:26
updateComponent@http://localhost:9876/base/index.js?ee5570e025c04344e0eea4f3a9a15f3d7ea0a523:9666:28
get@http://localhost:9876/base/index.js?ee5570e025c04344e0eea4f3a9a15f3d7ea0a523:10020:29
Watcher@http://localhost:9876/base/index.js?ee5570e025c04344e0eea4f3a9a15f3d7ea0a523:10009:15
mountComponent@http://localhost:9876/base/index.js?ee5570e025c04344e0eea4f3a9a15f3d7ea0a523:9673:14
$mount@http://localhost:9876/base/index.js?ee5570e025c04344e0eea4f3a9a15f3d7ea0a523:15418:24
$mount@http://localhost:9876/base/index.js?ee5570e025c04344e0eea4f3a9a15f3d7ea0a523:17817:20
http://localhost:9876/base/index.js?ee5570e025c04344e0eea4f3a9a15f3d7ea0a523:44003:38
callFn@http://localhost:9876/absoluteF:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js?8bf1d1adf34e719cca6e8f6915b9cd6eabf83d6b:4481:25
run@http://localhost:9876/absoluteF:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js?8bf1d1adf34e719cca6e8f6915b9cd6eabf83d6b:4473:13
runTest@http://localhost:9876/absoluteF:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js?8bf1d1adf34e719cca6e8f6915b9cd6eabf83d6b:4969:13
http://localhost:9876/absoluteF:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js?8bf1d1adf34e719cca6e8f6915b9cd6eabf83d6b:5075:19
next@http://localhost:9876/absoluteF:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js?8bf1d1adf34e719cca6e8f6915b9cd6eabf83d6b:4887:16
http://localhost:9876/absoluteF:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js?8bf1d1adf34e719cca6e8f6915b9cd6eabf83d6b:4897:11
next@http://localhost:9876/absoluteF:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js?8bf1d1adf34e719cca6e8f6915b9cd6eabf83d6b:4821:16
http://localhost:9876/absoluteF:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js?8bf1d1adf34e719cca6e8f6915b9cd6eabf83d6b:4865:9
timeslice@http://localhost:9876/absoluteF:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js?8bf1d1adf34e719cca6e8f6915b9cd6eabf83d6b:82:27', line: 53414, sourceURL: 'http://localhost:9PhantomJS 2.1.1 (Windows 7.0.0) Hello.vue should render correct contents FAILED
undefined is not a constructor (evaluating 'vm.$el.querySelector('p.alert-success')')
webpack:///test/unit/specs/Hello.spec.js:8:32 <- index.js:44004:32
callFn@F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:4481:25
run@F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:4473:13
runTest@F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:4969:13
F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:5075:19
next@F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:4887:16
F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:4897:11
next@F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:4821:16
F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:4865:9
timeslice@F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:82:27
PhantomJS 2.1.1 (Windows 7.0.0): Executed 1 of 1 (1 FAILED) (0 secs / 0.027 secs)
Hello.vue
×should render correct contents
undefined is not a constructor (evaluating 'vm.$el.querySelector('p.alert-success')')
webpack:///test/unit/specs/Hello.spec.js:8:32 <- index.js:44004:32
callFn@F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:4481:25
run@F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:4473:13
runTest@F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:4969:13
F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:5075:19
next@F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:4887:16
F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:4897:11
next@F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:4821:16
F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:4865:9
timeslice@F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:82:27
PhantomJS 2.1.1 (Windows 7.0.0): Executed 1 of 1 (1 FAILED) ERROR (0.466 secs / 0.027 secs)
PhantomJS 2.1.1 (Windows 7.0.0): Executed 1 of 1 (1 FAILED) ERROR (0.466 secs / 0.027 secs)
=============================== Coverage summary ===============================
Statements : 13.81% ( 74/536 )
Branches : 2.63% ( 5/190 )
Functions : 2.73% ( 3/110 )
Lines : 14.37% ( 74/515 )
================================================================================
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vue-esri@1.0.1 unit: `cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vue-esri@1.0.1 unit script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! D:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2018-04-18T11_20_11_739Z-debug.log
ERROR: '[Vue warn]: Error in render: "TypeError: undefined is not an object (evaluating '_vm.$route.query')"
(found in <Root>)'
Hello.vue
×should render correct contents
undefined is not a constructor (evaluating 'vm.$el.querySelector('p.alert-success')')
$ npm run unit
> vue-esri@1.0.1 unit F:\documentbak\4_18\bak\vue-esri
> cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run
18 04 2018 21:06:55.528:INFO [karma]: Karma v1.7.1 server started at http://0.0.0.0:9876/
18 04 2018 21:06:55.538:INFO [launcher]: Launching browser PhantomJS with unlimited concurrency
18 04 2018 21:06:55.556:INFO [launcher]: Starting browser PhantomJS
18 04 2018 21:06:59.704:INFO [PhantomJS 2.1.1 (Windows 7.0.0)]: Connected on socket FWOxVf2Ep6XzEbN_AAAA with id 65337975
ERROR: '[Vue warn]: Unknown custom element: <el-row> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
(found in <Root>)'
PhantomJS 2.1.1 (Windows 7.0.0): Executed 0 of 1 SUCCESS (0 secs / 0 secs)
ERROR LOG: '[Vue warn]: Unknown custom element: <el-row> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
ERROR: '[Vue warn]: Unknown custom element: <el-col> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
(found in <Root>)'
PhantomJS 2.1.1 (Windows 7.0.0): Executed 0 of 1 SUCCESS (0 secs / 0 secs)
ERROR LOG: '[Vue warn]: Unknown custom element: <el-col> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
ERROR: '[Vue warn]: Unknown custom element: <el-form> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
(found in <Root>)'
PhantomJS 2.1.1 (Windows 7.0.0): Executed 0 of 1 SUCCESS (0 secs / 0 secs)
ERROR LOG: '[Vue warn]: Unknown custom element: <el-form> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
ERROR: '[Vue warn]: Unknown custom element: <el-col> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
(found in <Root>)'
PhantomJS 2.1.1 (Windows 7.0.0): Executed 0 of 1 SUCCESS (0 secs / 0 secs)
ERROR LOG: '[Vue warn]: Unknown custom element: <el-col> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
ERROR: '[Vue warn]: Unknown custom element: <el-form-item> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
(found in <Root>)'
PhantomJS 2.1.1 (Windows 7.0.0): Executed 0 of 1 SUCCESS (0 secs / 0 secs)
ERROR LOG: '[Vue warn]: Unknown custom element: <el-form-item> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
ERROR: '[Vue warn]: Unknown custom element: <el-input> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
(found in <Root>)'
PhantomJS 2.1.1 (Windows 7.0.0): Executed 0 of 1 SUCCESS (0 secs / 0 secs)
ERROR LOG: '[Vue warn]: Unknown custom element: <el-input> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
ERROR: '[Vue warn]: Unknown custom element: <el-col> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
(found in <Root>)'
PhantomJS 2.1.1 (Windows 7.0.0): Executed 0 of 1 SUCCESS (0 secs / 0 secs)
ERROR LOG: '[Vue warn]: Unknown custom element: <el-col> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
ERROR: '[Vue warn]: Unknown custom element: <el-form-item> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
(found in <Root>)'
PhantomJS 2.1.1 (Windows 7.0.0): Executed 0 of 1 SUCCESS (0 secs / 0 secs)
ERROR LOG: '[Vue warn]: Unknown custom element: <el-form-item> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
ERROR: '[Vue warn]: Unknown custom element: <el-input> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
(found in <Root>)'
PhantomJS 2.1.1 (Windows 7.0.0): Executed 0 of 1 SUCCESS (0 secs / 0 secs)
ERROR LOG: '[Vue warn]: Unknown custom element: <el-input> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
ERROR: '[Vue warn]: Unknown custom element: <el-col> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
(found in <Root>)'
PhantomJS 2.1.1 (Windows 7.0.0): Executed 0 of 1 SUCCESS (0 secs / 0 secs)
ERROR LOG: '[Vue warn]: Unknown custom element: <el-col> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
ERROR: '[Vue warn]: Unknown custom element: <el-form-item> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
(found in <Root>)'
PhantomJS 2.1.1 (Windows 7.0.0): Executed 0 of 1 SUCCESS (0 secs / 0 secs)
ERROR LOG: '[Vue warn]: Unknown custom element: <el-form-item> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
ERROR: '[Vue warn]: Unknown custom element: <el-input> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
(found in <Root>)'
PhantomJS 2.1.1 (Windows 7.0.0): Executed 0 of 1 SUCCESS (0 secs / 0 secs)
ERROR LOG: '[Vue warn]: Unknown custom element: <el-input> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
ERROR: '[Vue warn]: Unknown custom element: <el-col> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
(found in <Root>)'
PhantomJS 2.1.1 (Windows 7.0.0): Executed 0 of 1 SUCCESS (0 secs / 0 secs)
ERROR LOG: '[Vue warn]: Unknown custom element: <el-col> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
ERROR: '[Vue warn]: Unknown custom element: <el-form-item> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
(found in <Root>)'
PhantomJS 2.1.1 (Windows 7.0.0): Executed 0 of 1 SUCCESS (0 secs / 0 secs)
ERROR LOG: '[Vue warn]: Unknown custom element: <el-form-item> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
ERROR: '[Vue warn]: Unknown custom element: <el-button> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
(found in <Root>)'
PhantomJS 2.1.1 (Windows 7.0.0): Executed 0 of 1 SUCCESS (0 secs / 0 secs)
ERROR LOG: '[Vue warn]: Unknown custom element: <el-button> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
ERROR: '[Vue warn]: Unknown custom element: <el-col> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
(found in <Root>)'
PhantomJS 2.1.1 (Windows 7.0.0): Executed 0 of 1 SUCCESS (0 secs / 0 secs)
ERROR LOG: '[Vue warn]: Unknown custom element: <el-col> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
ERROR: '[Vue warn]: Unknown custom element: <el-form-item> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
(found in <Root>)'
PhantomJS 2.1.1 (Windows 7.0.0): Executed 0 of 1 SUCCESS (0 secs / 0 secs)
ERROR LOG: '[Vue warn]: Unknown custom element: <el-form-item> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
ERROR: '[Vue warn]: Unknown custom element: <el-button> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
(found in <Root>)'
PhantomJS 2.1.1 (Windows 7.0.0): Executed 0 of 1 SUCCESS (0 secs / 0 secs)
ERROR LOG: '[Vue warn]: Unknown custom element: <el-button> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
PhantomJS 2.1.1 (Windows 7.0.0) Login.vue should render correct contents FAILED
null is not an object (evaluating 'vm.$el.querySelector('p.alert-success').textContent')
webpack:///test/unit/specs/Hello.spec.js:8:51 <- index.js:44004:51
callFn@F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:4481:25
run@F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:4473:13
runTest@F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:4969:13
F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:5075:19
next@F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:4887:16
F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:4897:11
next@F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:4821:16
F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:4865:9
timeslice@F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:82:27
PhantomJS 2.1.1 (Windows 7.0.0): Executed 1 of 1 (1 FAILED) (0 secs / 0.075 secs)
Login.vue
×should render correct contents
null is not an object (evaluating 'vm.$el.querySelector('p.alert-success').textContent')
webpack:///test/unit/specs/Hello.spec.js:8:51 <- index.js:44004:51
callFn@F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:4481:25
run@F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:4473:13
runTest@F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:4969:13
F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:5075:19
next@F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:4887:16
F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:4897:11
next@F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:4821:16
F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:4865:9
timeslice@F:/documentbak/4_18/bak/vue-esri/node_modules/_mocha@3.5.3@mocha/mocha.js:82:27
PhantomJS 2.1.1 (Windows 7.0.0): Executed 1 of 1 (1 FAILED) ERROR (0.689 secs / 0.075 secs)
PhantomJS 2.1.1 (Windows 7.0.0): Executed 1 of 1 (1 FAILED) ERROR (0.689 secs / 0.075 secs)
=============================== Coverage summary ===============================
Statements : 14.55% ( 78/536 )
Branches : 2.63% ( 5/190 )
Functions : 2.73% ( 3/110 )
Lines : 15.15% ( 78/515 )
================================================================================
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vue-esri@1.0.1 unit: `cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vue-esri@1.0.1 unit script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! D:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2018-04-18T13_07_02_174Z-debug.log
$ npm run unit
> vue-esri@1.0.1 unit F:\documentbak\4_18\bak\vue-esri
> cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run
18 04 2018 21:10:22.795:INFO [karma]: Karma v1.7.1 server started at http://0.0.0.0:9876/
18 04 2018 21:10:22.804:INFO [launcher]: Launching browser PhantomJS with unlimited concurrency
18 04 2018 21:10:22.824:INFO [launcher]: Starting browser PhantomJS
18 04 2018 21:10:27.143:INFO [PhantomJS 2.1.1 (Windows 7.0.0)]: Connected on socket voWWsOHewTgYnN5UAAAA with id 90720330
PhantomJS 2.1.1 (Windows 7.0.0) Hello.vue should render correct contents FAILED
expected '\n 由西瓜酱提供包含三种颜色主题的vue后台操作模板\n ' to equal '由西瓜酱提供包含三种颜色主题的vue后台操作模板'
PhantomJS 2.1.1 (Windows 7.0.0): Executed 1 of 1 (1 FAILED) (0 secs / 0.032 secs)
Hello.vue
×should render correct contents
expected '\n 由西瓜酱提供包含三种颜色主题的vue后台操作模板\n ' to equal '由西瓜酱提供包含三种颜色主题的vue后台操作模板'
PhantomJS 2.1.1 (Windows 7.0.0): Executed 1 of 1 (1 FAILED) ERROR (0.078 secs / 0.032 secs)
PhantomJS 2.1.1 (Windows 7.0.0): Executed 1 of 1 (1 FAILED) ERROR (0.078 secs / 0.032 secs)
=============================== Coverage summary ===============================
Statements : 13.81% ( 74/536 )
Branches : 2.63% ( 5/190 )
Functions : 2.73% ( 3/110 )
Lines : 14.37% ( 74/515 )
================================================================================
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! vue-esri@1.0.1 unit: `cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the vue-esri@1.0.1 unit script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! D:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2018-04-18T13_10_29_409Z-debug.log
./test/unit/specs/Hello.spec.js
文件为import Vue from 'vue'
import Hello from '@/pages/Hello'
describe('Hello.vue', () => {
it('should render correct contents', () => {
const Constructor = Vue.extend(Hello)
const vm = new Constructor().$mount()
expect(vm.$el.querySelector('p.alert-success').textContent)
.to.equal('\n 由西瓜酱提供包含三种颜色主题的vue后台操作模板\n ')
})
})
$ npm run unit
> vue-esri@1.0.1 unit F:\documentbak\4_18\bak\vue-esri
> cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run
18 04 2018 21:15:03.015:INFO [karma]: Karma v1.7.1 server started at http://0.0.0.0:9876/
18 04 2018 21:15:03.024:INFO [launcher]: Launching browser PhantomJS with unlimited concurrency
18 04 2018 21:15:03.044:INFO [launcher]: Starting browser PhantomJS
18 04 2018 21:15:07.290:INFO [PhantomJS 2.1.1 (Windows 7.0.0)]: Connected on socket MGiQ9ekueKo13qkcAAAA with id 93646375
PhantomJS 2.1.1 (Windows 7.0.0): Executed 1 of 1 SUCCESS (0 secs / 0.028 secs)
Hello.vue
PhantomJS 2.1.1 (Windows 7.0.0): Executed 1 of 1 SUCCESS (0.053 secs / 0.028 secs)
PhantomJS 2.1.1 (Windows 7.0.0): Executed 1 of 1 SUCCESS (0.053 secs / 0.028 secs)
TOTAL: 1 SUCCESS
=============================== Coverage summary ===============================
Statements : 13.81% ( 74/536 )
Branches : 2.63% ( 5/190 )
Functions : 2.73% ( 3/110 )
Lines : 14.37% ( 74/515 )
================================================================================
终于有一个完全通过的案例,可喜可贺。
http://fengmk2.github.io/ppt/unittest-and-bdd-in-nodejs-with-mocha.html
Who am I?我是谁? Alibaba Data EDP 阿里巴巴数据平台EDP,花名@苏千 CNode, Chinese nodejs community cnodejs.org Github: @fengmk2 Blog: http://fengmk2.github.com Twitter: @fengmk2 Weibo: @Python发烧友 , @FaWave