Skip to content

Commit

Permalink
Merge pull request mozilla#12153 from timvandermeij/jasmine
Browse files Browse the repository at this point in the history
Unit test improvements
  • Loading branch information
timvandermeij authored Aug 1, 2020
2 parents 252f2ba + c53e403 commit 277a92d
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 32 deletions.
91 changes: 67 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"gulp-rename": "^1.4.0",
"gulp-replace": "^1.0.0",
"gulp-zip": "^4.2.0",
"jasmine": "~3.5.0",
"jasmine": "^3.6.1",
"jsdoc": "^3.6.5",
"jstransformer-markdown-it": "^2.1.0",
"merge-stream": "^1.0.1",
Expand Down
30 changes: 23 additions & 7 deletions test/unit/testreporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,37 @@ var TestReporter = function (browser) {

this.jasmineStarted = function (suiteInfo) {
this.runnerStartTime = this.now();
sendInfo("Started tests for " + browser + ".");

const total = suiteInfo.totalSpecsDefined;
const seed = suiteInfo.order.seed;
sendInfo(`Started ${total} tests for ${browser} with seed ${seed}.`);
};

this.suiteStarted = function (result) {};
this.suiteStarted = function (result) {
// Normally suite starts don't have to be reported because the individual
// specs inside them are reported, but it can happen that the suite cannot
// start, for instance due to an uncaught exception in `beforeEach`. This
// is problematic because the specs inside the suite will never be found
// and run, so if we don't report the suite start failure here it would be
// ignored silently, leading to passing tests even though some did not run.
if (result.failedExpectations.length > 0) {
let failedMessages = "";
for (const item of result.failedExpectations) {
failedMessages += `${item.message} `;
}
sendResult("TEST-UNEXPECTED-FAIL", result.description, failedMessages);
}
};

this.specStarted = function (result) {};

this.specDone = function (result) {
if (result.failedExpectations.length === 0) {
sendResult("TEST-PASSED", result.description);
} else {
var failedMessages = "";
var items = result.failedExpectations;
for (var i = 0, ii = items.length; i < ii; i++) {
failedMessages += items[i].message + " ";
let failedMessages = "";
for (const item of result.failedExpectations) {
failedMessages += `${item.message} `;
}
sendResult("TEST-UNEXPECTED-FAIL", result.description, failedMessages);
}
Expand All @@ -71,7 +87,7 @@ var TestReporter = function (browser) {
this.suiteDone = function (result) {};

this.jasmineDone = function () {
// Give the test.py some time process any queued up requests
// Give the test runner some time process any queued requests.
setTimeout(sendQuitRequest, 500);
};
};

0 comments on commit 277a92d

Please sign in to comment.