diff --git a/package.json b/package.json index 2c969bee6c4..35caaf4fe0b 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "test:cover": "karma start test/unit/karma.cover.config.js", "test:e2e": "npm run build -- web-full-prod,web-server-basic-renderer && node test/e2e/runner.js", "test:weex": "npm run build:weex && jasmine JASMINE_CONFIG_PATH=test/weex/jasmine.json", + "test:weex:cover": "ISTANBUL=true npm run build:weex && nyc --nycrc-path test/weex/.nycrc jasmine JASMINE_CONFIG_PATH=test/weex/jasmine.json", "test:ssr": "npm run build:ssr && jasmine JASMINE_CONFIG_PATH=test/ssr/jasmine.json", "test:sauce": "npm run sauce -- 0 && npm run sauce -- 1 && npm run sauce -- 2", "test:types": "tsc -p ./types/test/tsconfig.json", @@ -120,6 +121,7 @@ "lru-cache": "^4.1.1", "nightwatch": "^0.9.16", "nightwatch-helpers": "^1.2.0", + "nyc": "^11.6.0", "phantomjs-prebuilt": "^2.1.14", "resolve": "^1.3.3", "rollup": "^0.54.1", @@ -128,6 +130,7 @@ "rollup-plugin-buble": "^0.19.2", "rollup-plugin-commonjs": "^8.0.0", "rollup-plugin-flow-no-whitespace": "^1.0.0", + "rollup-plugin-istanbul": "^2.0.1", "rollup-plugin-node-resolve": "^3.0.0", "rollup-plugin-replace": "^2.0.0", "rollup-watch": "^4.0.0", diff --git a/scripts/config.js b/scripts/config.js index 4fe40552521..390c8b8da23 100644 --- a/scripts/config.js +++ b/scripts/config.js @@ -3,10 +3,12 @@ const buble = require('rollup-plugin-buble') const alias = require('rollup-plugin-alias') const cjs = require('rollup-plugin-commonjs') const replace = require('rollup-plugin-replace') +const istanbul = require('rollup-plugin-istanbul') const node = require('rollup-plugin-node-resolve') const flow = require('rollup-plugin-flow-no-whitespace') const version = process.env.VERSION || require('../package.json').version const weexVersion = process.env.WEEX_VERSION || require('../packages/weex-vue-framework/package.json').version +const istanbulInstrument = process.env.ISTANBUL const banner = '/*!\n' + @@ -197,6 +199,12 @@ function genConfig (name) { })) } + if (istanbulInstrument) { + config.plugins.push(istanbul({ + exclude: ['test/**/*.js'] + })) + } + Object.defineProperty(config, '_name', { enumerable: false, value: name diff --git a/src/platforms/weex/entry-framework.js b/src/platforms/weex/entry-framework.js index a23775d4db5..36216868213 100644 --- a/src/platforms/weex/entry-framework.js +++ b/src/platforms/weex/entry-framework.js @@ -137,6 +137,7 @@ function createVueModuleInstance ( * Get instance config. * @return {object} */ + /* istanbul ignore next */ Vue.prototype.$getConfig = function () { if (instance.app instanceof Vue) { return instance.config @@ -153,6 +154,7 @@ function createVueModuleInstance ( * framework can make sure no side effect of the callback happened after * an instance destroyed. */ +/* istanbul ignore next */ function getInstanceTimer ( instanceId: string, moduleGetter: Function diff --git a/src/platforms/weex/runtime/modules/class.js b/src/platforms/weex/runtime/modules/class.js index 47620552346..d2e501829b5 100755 --- a/src/platforms/weex/runtime/modules/class.js +++ b/src/platforms/weex/runtime/modules/class.js @@ -18,6 +18,7 @@ function updateClass (oldVnode: VNodeWithData, vnode: VNodeWithData) { const oldClassList = makeClassList(oldData) const classList = makeClassList(data) + /* istanbul ignore else */ if (typeof el.setClassList === 'function') { el.setClassList(classList) } else { @@ -48,6 +49,7 @@ function makeClassList (data: VNodeData): Array { return classList } +/* istanbul ignore next */ function getStyle (oldClassList: Array, classList: Array, ctx: Component): Object { // style is a weex-only injected object // compiled from