Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use karma-browserify for tests. Add browser test coverage reporter. #1376

Merged
merged 4 commits into from Jan 27, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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