Skip to content

Commit

Permalink
Merge pull request #156 from naugtur/change-browser-runner
Browse files Browse the repository at this point in the history
Change browser runner
  • Loading branch information
naugtur authored Apr 13, 2017
2 parents edb89cf + f1a21b7 commit b9544c2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
language: node_js
addons:
apt:
packages:
- xvfb
install:
- export DISPLAY=':99.0'
- Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
- npm install
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,23 @@
"email": "[email protected]"
},
"dependencies": {
"browserify": "^13.3.0",
"global": "~4.3.0",
"is-function": "^1.0.1",
"parse-headers": "^2.0.0",
"xtend": "^4.0.0"
},
"devDependencies": {
"browser-run": "3.5.0",
"browserify": "^13.1.1",
"for-each": "^0.3.2",
"pre-commit": "1.2.2",
"run-browser": "naugtur/run-browser",
"tap-spec": "^4.0.2",
"tape": "^4.0.0"
},
"license": "MIT",
"scripts": {
"test": "run-browser test/index.js -b -m test/mock-server.js | tap-spec",
"browser": "run-browser -m test/mock-server.js test/index.js"
"test": "browserify test/index.js | browser-run -m test/mock-server.js | tap-spec",
"browser": "browserify test/index.js | browser-run -p 8080 -m test/mock-server.js | tap-spec"
}
}
14 changes: 14 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ var forEach = require("for-each")

var xhr = require("../index.js")

test("tests are run from http protocol", { timeout: 500 }, function(assert) {
console.log(window.origin, window.location)
assert.notEqual(window.location.protocol, "file:")
assert.end()
})

test("constructs and calls callback without throwing", { timeout: 500 }, function(assert) {
xhr({}, function(err, resp, body) {
assert.ok(true, "got here")
Expand Down Expand Up @@ -84,8 +90,11 @@ test("[func] Returns a falsy body for 2xx responses", { timeout: 500 }, function
test("[func] Calls the callback at most once even if error is thrown issue #127", { timeout: 500 }, function(assert) {
//double call happened in chrome
var count = 0;
var onerror = window.onerror
window.onerror = console.error.bind(console)
setTimeout(function() {
assert.ok(count <= 1, "expected at most one call")
window.onerror = onerror
assert.end()
}, 100)
try {
Expand Down Expand Up @@ -376,3 +385,8 @@ test("XHR can be overridden", { timeout: 500 }, function(assert) {
assert.equal(xdrs, 1, "created the custom XDR")
assert.end()
})

test('close browser after everything', function(assert) {
assert.end()
setTimeout(window.close,100)
})

0 comments on commit b9544c2

Please sign in to comment.