2018-05-02 16:51:22 +00:00
|
|
|
mocha.setup('bdd');
|
2015-01-14 01:04:21 +00:00
|
|
|
window.assert = chai.assert;
|
2017-12-01 21:35:39 +00:00
|
|
|
window.PROTO_ROOT = '../../protos';
|
2015-01-14 01:04:21 +00:00
|
|
|
|
|
|
|
(function() {
|
2018-07-21 21:51:20 +00:00
|
|
|
const OriginalReporter = mocha._reporter;
|
2015-01-14 01:04:21 +00:00
|
|
|
|
2018-07-21 21:51:20 +00:00
|
|
|
const SauceReporter = function(runner) {
|
|
|
|
const failedTests = [];
|
2015-01-14 01:04:21 +00:00
|
|
|
|
2018-07-21 21:51:20 +00:00
|
|
|
runner.on('end', () => {
|
2015-01-14 01:04:21 +00:00
|
|
|
window.mochaResults = runner.stats;
|
|
|
|
window.mochaResults.reports = failedTests;
|
|
|
|
});
|
|
|
|
|
2018-07-21 21:51:20 +00:00
|
|
|
runner.on('fail', (test, err) => {
|
|
|
|
const flattenTitles = function(test) {
|
|
|
|
const titles = [];
|
2015-01-14 01:04:21 +00:00
|
|
|
while (test.parent.title) {
|
|
|
|
titles.push(test.parent.title);
|
|
|
|
test = test.parent;
|
|
|
|
}
|
|
|
|
return titles.reverse();
|
|
|
|
};
|
|
|
|
failedTests.push({
|
|
|
|
name: test.title,
|
|
|
|
result: false,
|
|
|
|
message: err.message,
|
|
|
|
stack: err.stack,
|
2018-05-02 16:51:22 +00:00
|
|
|
titles: flattenTitles(test),
|
2015-01-14 01:04:21 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
new OriginalReporter(runner);
|
|
|
|
};
|
|
|
|
|
|
|
|
SauceReporter.prototype = OriginalReporter.prototype;
|
|
|
|
|
|
|
|
mocha.reporter(SauceReporter);
|
2018-05-02 16:51:22 +00:00
|
|
|
})();
|
2015-01-14 01:04:21 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* global helpers for tests
|
|
|
|
*/
|
|
|
|
function assertEqualArrayBuffers(ab1, ab2) {
|
|
|
|
assert.deepEqual(new Uint8Array(ab1), new Uint8Array(ab2));
|
2018-05-02 16:51:22 +00:00
|
|
|
}
|
2015-01-14 01:04:21 +00:00
|
|
|
|
|
|
|
function hexToArrayBuffer(str) {
|
2018-07-21 21:51:20 +00:00
|
|
|
const ret = new ArrayBuffer(str.length / 2);
|
|
|
|
const array = new Uint8Array(ret);
|
|
|
|
for (let i = 0; i < str.length / 2; i++)
|
2018-05-02 16:51:22 +00:00
|
|
|
array[i] = parseInt(str.substr(i * 2, 2), 16);
|
2015-01-14 01:04:21 +00:00
|
|
|
return ret;
|
2018-05-02 16:51:22 +00:00
|
|
|
}
|
2017-12-01 21:35:39 +00:00
|
|
|
|
|
|
|
window.MockSocket.prototype.addEventListener = function() {};
|