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

Add browser test to keep track of browserify compability. #1308

Merged
merged 6 commits into from Dec 9, 2014
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 .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()
})
})