Skip to content

Commit

Permalink
Merge pull request #1308 from eiriksm/feat/browserify-tests
Browse files Browse the repository at this point in the history
Add browser test to keep track of browserify compability.
  • Loading branch information
nylen committed Dec 9, 2014
2 parents 6f6e398 + 66b1755 commit aeef0cd
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 4 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -2,6 +2,7 @@ language: node_js
node_js:
- "0.8"
- "0.10"
before_install: npm install -g npm@~1.4.6
after_script: ./node_modules/.bin/istanbul cover ./node_modules/tape/bin/tape tests/test-*.js --report lcovonly && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js --verbose
webhooks:
urls: https://webhooks.gitter.im/e/237280ed4796c19cc626
Expand Down
15 changes: 11 additions & 4 deletions package.json 100755 → 100644
Expand Up @@ -40,15 +40,22 @@
"combined-stream": "~0.0.5"
},
"scripts": {
"test": "npm run lint && node node_modules/.bin/taper tests/test-*.js",
"test": "npm run lint && node node_modules/.bin/taper tests/test-*.js && npm run test-browser",
"test-browser": "browserify tests/browser/test.js -o tests/browser/test-browser.js && karma start tests/browser/karma.conf.js",
"lint": "node node_modules/.bin/eslint lib/ *.js tests/ && echo Lint passed."
},
"devDependencies": {
"browserify": "~5.9.1",
"coveralls": "~2.11.2",
"eslint": "0.5.1",
"function-bind": "~1.0.0",
"istanbul": "~0.3.2",
"karma": "~0.12.21",
"karma-cli": "0.0.4",
"karma-phantomjs-launcher": "~0.1.4",
"karma-tap": "~1.0.1",
"rimraf": "~2.2.8",
"tape": "~3.0.0",
"taper": "~0.3.0",
"istanbul": "~0.3.2",
"coveralls": "~2.11.2"
"taper": "~0.3.0"
}
}
24 changes: 24 additions & 0 deletions tests/browser/karma.conf.js
@@ -0,0 +1,24 @@
'use strict'

module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['tap'],
files: [
'test-browser.js'
],
port: 9876,

reporters: ['dots'],

colors: true,

logLevel: config.LOG_ERROR,

autoWatch: false,

browsers: ['PhantomJS'],

singleRun: true
})
}
25 changes: 25 additions & 0 deletions tests/browser/test.js
@@ -0,0 +1,25 @@
'use strict'

if (!Function.prototype.bind) {
// This is because of the fact that phantom.js does not have Function.bind.
// This is a bug in phantom.js.
// More info: https://github.com/ariya/phantomjs/issues/10522
/*eslint no-extend-native:0*/
Function.prototype.bind = require('function-bind')
}


var assert = require('assert')
, tape = require('tape')
, request = require('../../index')

tape('Request browser test', function(t) {
t.plan(1)
request({
uri: 'https://api.github.com',
withCredentials: false
}, function (error, response) {
t.equal(response.statusCode, 200)
t.end()
})
})

0 comments on commit aeef0cd

Please sign in to comment.