Skip to content

Commit

Permalink
Merge pull request #1376 from eiriksm/feat/karma-browserify-coverage
Browse files Browse the repository at this point in the history
Use karma-browserify for tests. Add browser test coverage reporter.
  • Loading branch information
nylen committed Jan 27, 2015
2 parents e5c295b + 880513a commit defc3b6
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
1 change: 1 addition & 0 deletions .npmignore
@@ -1,2 +1,3 @@
coverage
tests
node_modules
8 changes: 5 additions & 3 deletions package.json
Expand Up @@ -42,18 +42,20 @@
},
"scripts": {
"test": "npm run lint && node node_modules/.bin/taper tests/test-*.js && npm run test-browser && npm run clean",
"test-browser": "browserify tests/browser/test.js -o tests/browser/test-browser.js && node tests/browser/start.js",
"lint": "node node_modules/.bin/eslint lib/ *.js tests/ && echo Lint passed.",
"clean": "rm tests/browser/test-browser.js || true"
"test-browser": "node tests/browser/start.js",
"lint": "node node_modules/.bin/eslint lib/ *.js tests/ && echo Lint passed."
},
"devDependencies": {
"browserify": "~5.9.1",
"browserify-istanbul": "~0.1.3",
"coveralls": "~2.11.2",
"eslint": "0.5.1",
"function-bind": "~1.0.0",
"istanbul": "~0.3.2",
"karma": "~0.12.21",
"karma-browserify": "~3.0.1",
"karma-cli": "0.0.4",
"karma-coverage": "0.2.6",
"karma-phantomjs-launcher": "~0.1.4",
"karma-tap": "~1.0.1",
"rimraf": "~2.2.8",
Expand Down
30 changes: 26 additions & 4 deletions tests/browser/karma.conf.js
@@ -1,15 +1,20 @@
'use strict'
var istanbul = require('browserify-istanbul')

module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['tap'],
basePath: '../..',
frameworks: ['tap', 'browserify'],
preprocessors: {
'tests/browser/test.js': ['browserify'],
'*.js,!(tests)/**/*.js': ['coverage']
},
files: [
'test-browser.js'
'tests/browser/test.js'
],
port: 9876,

reporters: ['dots'],
reporters: ['dots', 'coverage'],

colors: true,

Expand All @@ -21,6 +26,23 @@ module.exports = function(config) {

singleRun: true,

plugins: [
'karma-phantomjs-launcher',
'karma-coverage',
'karma-browserify',
'karma-tap'
],
browserify: {
debug: true,
transform: [istanbul({
ignore: ['**/node_modules/**', '**/tests/**']
})]
},
coverageReporter: {
type: 'lcov',
dir: 'coverage/'
},

// Custom launcher to allowe self signed certs.
customLaunchers: {
PhantomJS_without_security: {
Expand Down
1 change: 1 addition & 0 deletions tests/browser/start.js
Expand Up @@ -26,6 +26,7 @@ server.listen(port, function() {
path.join(__dirname, '/karma.conf.js')
])
c.stdout.pipe(process.stdout)
c.stderr.pipe(process.stderr)
c.on('exit', function(c) {
// Exit process with karma exit code.
if (c !== 0) {
Expand Down

0 comments on commit defc3b6

Please sign in to comment.