Closed Eccentris closed 6 years ago
Hi! I can't seem to get my coverage to show correctly, but the unit tests are running as they should. The coverage always shows 100% like so:
Coverage summary Statements : 100% ( 0/0 ) Branches : 100% ( 0/0 ) Functions : 100% ( 0/0 ) Lines : 100% ( 0/0 )
My karma.conf.js looks like this
module.exports = function(config) { var autoprefixer = require('autoprefixer'); process.env.BABEL_ENV = 'testing-unit'; config.set({ basePath: '', frameworks: ['jasmine', 'browserify'], browserify: { debug: true, transform: [ ['vueify', { postcss: [autoprefixer( {browsers: ['last 2 versions', 'ie 11']})] }], ['babelify'] ], }, files: [ 'tests/js/**/*.js' ], preprocessors: { '/src/js/**/*.vue': ['coverage'], '/src/js/**/*.js': ['coverage'], 'tests/js/**/*.js': ['browserify'] }, reporters: ['spec', 'coverage'], coverageReporter: { dir: 'reports/coverage/javascript', includeAllSources: true, reporters: [ { type: 'lcov', subdir: '.' }, { type: 'text-summary' }, { type: 'text' }, { type: 'cobertura', subdir: '.', file: 'coverage.xml' } ] }, junitReporter: { outputFile: 'reports/test-results.xml', useBrowserName: false }, port: 9876, colors: true, logLevel: config.LOG_INFO, autoWatch: false, browsers: ['PhantomJS'], singleRun: false, concurrency: Infinity }) }
I've only written tests for one vue file, covering maybe 50% of that file, but I have many more untested src files so I'd expect the coverage to be much lower.
My package.json:
"devDependencies": { "@mapbox/stylelint-processor-arbitrary-tags": "^0.2.0", "@vue/test-utils": "^1.0.0-beta.13", "ajv": "^5.3.0", "autoprefixer": "^7.1.4", "babel-cli": "^6.26.0", "babel-preset-env": "^1.6.1", "babelify": "^8.0.0", "eslint": "^4.17.0", "eslint-plugin-vue": "4.3.0", "grunt": "^1.0.2", "grunt-browserify": "^5.2.0", "grunt-contrib-clean": "^1.1.0", "grunt-contrib-copy": "^1.0.0", "grunt-contrib-less": "^1.4.1", "grunt-contrib-watch": "^1.0.0", "grunt-eslint": "^20.1.0", "grunt-postcss": "^0.9.0", "grunt-stylelint": "^0.9.0", "jasmine": "^2.5.3", "karma": "^2.0.0", "karma-browserify": "^5.3.0", "karma-cli": "^1.0.1", "karma-coverage": "^1.1.1", "karma-jasmine": "^1.1.1", "karma-junit-reporter": "^1.2.0", "karma-phantomjs-launcher": "^1.0.4", "karma-spec-reporter": "0.0.32", "stylelint": "^8.2.0", "stylelint-config-standard": "^17.0.0", "vueify": "^9.4.1" }, "dependencies": { "@fortawesome/fontawesome": "^1.1.5", "@fortawesome/fontawesome-free-solid": "^5.0.10", "@fortawesome/vue-fontawesome": "0.0.22", "core-js": "^2.5.3", "normalize.css": "^7.0.0", "pikaday": "^1.6.1", "v-tooltip": "^2.0.0-rc.32", "vue": "^2.5.13", "whatwg-fetch": "^2.0.4" }, "browser": { "vue": "vue/dist/vue.common.js" }, "scripts": { "test": "npm run test:browser", "test:browser": "karma start --single-run --browsers PhantomJS", "test:ci": "npm run test:browser -- --reporters spec,coverage,junit" }
Found the issue, it was due to using karma coverage and browserify at the same time. Using browserify-istanbul solved it.
Hi! I can't seem to get my coverage to show correctly, but the unit tests are running as they should. The coverage always shows 100% like so:
Coverage summary Statements : 100% ( 0/0 ) Branches : 100% ( 0/0 ) Functions : 100% ( 0/0 ) Lines : 100% ( 0/0 )
My karma.conf.js looks like this
I've only written tests for one vue file, covering maybe 50% of that file, but I have many more untested src files so I'd expect the coverage to be much lower.
My package.json: