Skip to content

Commit 277a92d

Browse files
Merge pull request #12153 from timvandermeij/jasmine
Unit test improvements
2 parents 252f2ba + c53e403 commit 277a92d

File tree

3 files changed

+91
-32
lines changed

3 files changed

+91
-32
lines changed

package-lock.json

+67-24
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"gulp-rename": "^1.4.0",
3333
"gulp-replace": "^1.0.0",
3434
"gulp-zip": "^4.2.0",
35-
"jasmine": "~3.5.0",
35+
"jasmine": "^3.6.1",
3636
"jsdoc": "^3.6.5",
3737
"jstransformer-markdown-it": "^2.1.0",
3838
"merge-stream": "^1.0.1",

test/unit/testreporter.js

+23-7
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,37 @@ var TestReporter = function (browser) {
4848

4949
this.jasmineStarted = function (suiteInfo) {
5050
this.runnerStartTime = this.now();
51-
sendInfo("Started tests for " + browser + ".");
51+
52+
const total = suiteInfo.totalSpecsDefined;
53+
const seed = suiteInfo.order.seed;
54+
sendInfo(`Started ${total} tests for ${browser} with seed ${seed}.`);
5255
};
5356

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

5673
this.specStarted = function (result) {};
5774

5875
this.specDone = function (result) {
5976
if (result.failedExpectations.length === 0) {
6077
sendResult("TEST-PASSED", result.description);
6178
} else {
62-
var failedMessages = "";
63-
var items = result.failedExpectations;
64-
for (var i = 0, ii = items.length; i < ii; i++) {
65-
failedMessages += items[i].message + " ";
79+
let failedMessages = "";
80+
for (const item of result.failedExpectations) {
81+
failedMessages += `${item.message} `;
6682
}
6783
sendResult("TEST-UNEXPECTED-FAIL", result.description, failedMessages);
6884
}
@@ -71,7 +87,7 @@ var TestReporter = function (browser) {
7187
this.suiteDone = function (result) {};
7288

7389
this.jasmineDone = function () {
74-
// Give the test.py some time process any queued up requests
90+
// Give the test runner some time process any queued requests.
7591
setTimeout(sendQuitRequest, 500);
7692
};
7793
};

0 commit comments

Comments
 (0)