mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-15 00:03:28 +01:00
Run Karma tests against Microsoft Edge
* Increase the default timeouts to account for the relative slowness of setting up connections to remote browsers. * Change the URL into which Wombat JS is loaded for tests to be a valid URL. Under Microsoft Edge, the JS code in the page is not run if the URL fetch returns a 404. * Change assert.equal() implementation to avoid confusion due to Karma's reformatting of URLs in exception error messages.
This commit is contained in:
parent
e4e3de85e2
commit
1997c4a180
9
karma-tests/dummy.html
Normal file
9
karma-tests/dummy.html
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<html>
|
||||||
|
<head><meta charset="UTF-8"></head>
|
||||||
|
<body>
|
||||||
|
<!-- This is a dummy page used in
|
||||||
|
tests of Wombat's live-rewriting
|
||||||
|
functionality.
|
||||||
|
!-->
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -28,18 +28,10 @@ var sauceLaunchers = {
|
|||||||
version: '9.0',
|
version: '9.0',
|
||||||
},
|
},
|
||||||
|
|
||||||
/* Edge is currently broken in
|
|
||||||
pywb.
|
|
||||||
|
|
||||||
See: https://github.com/ikreymer/pywb/issues/148 (Edge)
|
|
||||||
https://github.com/ikreymer/pywb/issues/147 (Safari)
|
|
||||||
|
|
||||||
|
|
||||||
sl_edge: {
|
sl_edge: {
|
||||||
base: 'SauceLabs',
|
base: 'SauceLabs',
|
||||||
browserName: 'MicrosoftEdge',
|
browserName: 'MicrosoftEdge',
|
||||||
},
|
},
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var localLaunchers = {
|
var localLaunchers = {
|
||||||
@ -73,6 +65,11 @@ module.exports = function(config) {
|
|||||||
included: false,
|
included: false,
|
||||||
served: true,
|
served: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
pattern: 'karma-tests/dummy.html',
|
||||||
|
included: false,
|
||||||
|
served: true,
|
||||||
|
},
|
||||||
'karma-tests/*.spec.js',
|
'karma-tests/*.spec.js',
|
||||||
],
|
],
|
||||||
|
|
||||||
@ -90,12 +87,15 @@ module.exports = function(config) {
|
|||||||
|
|
||||||
sauceLabs: sauceLabsConfig,
|
sauceLabs: sauceLabsConfig,
|
||||||
|
|
||||||
// use an extended timeout for capturing Sauce Labs
|
// Set extended timeouts to account for the slowness
|
||||||
// browsers and waiting for activity
|
// in connecting to remote browsers (eg. when using
|
||||||
// in case the service is busy
|
// Sauce Labs)
|
||||||
|
//
|
||||||
|
// See https://oligofren.wordpress.com/2014/05/27/running-karma-tests-on-browserstack/
|
||||||
captureTimeout: 3 * 60000,
|
captureTimeout: 3 * 60000,
|
||||||
|
|
||||||
browserNoActivityTimeout: 30 * 1000,
|
browserNoActivityTimeout: 30 * 1000,
|
||||||
|
browserDisconnectTimeout: 10 * 1000,
|
||||||
|
browserDisconnectTolerance: 1,
|
||||||
|
|
||||||
customLaunchers: customLaunchers,
|
customLaunchers: customLaunchers,
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
var WOMBAT_SRC = '../pywb/static/wombat.js';
|
|
||||||
var DEFAULT_TIMEOUT = 20000;
|
var DEFAULT_TIMEOUT = 20000;
|
||||||
|
|
||||||
// creates a new document in an <iframe> and runs
|
// creates a new document in an <iframe> and runs
|
||||||
@ -12,7 +11,7 @@ var DEFAULT_TIMEOUT = 20000;
|
|||||||
function runWombatTest(testCase, done) {
|
function runWombatTest(testCase, done) {
|
||||||
// create an <iframe>
|
// create an <iframe>
|
||||||
var testFrame = document.createElement('iframe');
|
var testFrame = document.createElement('iframe');
|
||||||
testFrame.src = '/dummy.html';
|
testFrame.src = '/base/karma-tests/dummy.html';
|
||||||
document.body.appendChild(testFrame);
|
document.body.appendChild(testFrame);
|
||||||
|
|
||||||
testFrame.contentWindow.addEventListener('load', function () {
|
testFrame.contentWindow.addEventListener('load', function () {
|
||||||
@ -27,8 +26,20 @@ function runWombatTest(testCase, done) {
|
|||||||
done(new Error(ex));
|
done(new Error(ex));
|
||||||
};
|
};
|
||||||
|
|
||||||
// expose chai assertions to the <iframe>
|
// expose utility methods for assertion testing in tests.
|
||||||
window.assert = assert;
|
// (We used to expose chai asserts here but Karma's default
|
||||||
|
// error reporter replaces URLs in exception messages with
|
||||||
|
// the corresponding file paths, which is unhelpful for us
|
||||||
|
// since assert.equal() will often be called with URLs in our tests)
|
||||||
|
window.assert = {
|
||||||
|
equal: function (a, b) {
|
||||||
|
if (a !== b) {
|
||||||
|
x.equal(a, b);
|
||||||
|
console.error('Mismatch between', a, 'and', b);
|
||||||
|
throw new Error('AssertionError');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
runFunctionInIFrame(function () {
|
runFunctionInIFrame(function () {
|
||||||
// re-assign the iframe's console object to the parent window's
|
// re-assign the iframe's console object to the parent window's
|
||||||
@ -136,7 +147,7 @@ describe('WombatJS', function () {
|
|||||||
testScript: function () {
|
testScript: function () {
|
||||||
var link = document.getElementById('link');
|
var link = document.getElementById('link');
|
||||||
if (domTests.areDOMPropertiesConfigurable()) {
|
if (domTests.areDOMPropertiesConfigurable()) {
|
||||||
assert.equal(link.href, 'http:///foobar.html');
|
assert.equal(link.href, 'http:///base/karma-tests/foobar.html');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}, done);
|
}, done);
|
||||||
@ -160,7 +171,7 @@ describe('WombatJS', function () {
|
|||||||
throw new Error('baseURI is not a string');
|
throw new Error('baseURI is not a string');
|
||||||
}
|
}
|
||||||
if (domTests.areDOMPropertiesConfigurable()) {
|
if (domTests.areDOMPropertiesConfigurable()) {
|
||||||
assert.equal(baseURI, 'http:///dummy.html');
|
assert.equal(baseURI, 'http:///base/karma-tests/dummy.html');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}, done);
|
}, done);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user