Skip to content

Commit 823f961

Browse files
authored
feat(testrunner): migrate from events to a delegate (#1647)
This allows an async handler for each event that can be awaited. Drive-by: merge TestPass into TestRunner.
1 parent f216ab9 commit 823f961

File tree

3 files changed

+143
-148
lines changed

3 files changed

+143
-148
lines changed

utils/testrunner/Reporter.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,10 @@ class Reporter {
3333
this._verbose = verbose;
3434
this._summary = summary;
3535
this._testCounter = 0;
36-
runner.on('started', this._onStarted.bind(this));
37-
runner.on('finished', this._onFinished.bind(this));
38-
runner.on('teststarted', this._onTestStarted.bind(this));
39-
runner.on('testfinished', this._onTestFinished.bind(this));
36+
runner.setDelegate(this);
4037
}
4138

42-
_onStarted(testRuns) {
39+
onStarted(testRuns) {
4340
this._testCounter = 0;
4441
this._timestamp = Date.now();
4542
const allTests = this._runner.tests();
@@ -83,7 +80,7 @@ class Reporter {
8380
console.log('');
8481
}
8582

86-
_onFinished(result) {
83+
onFinished(result) {
8784
this._printTestResults(result);
8885
if (!result.ok())
8986
this._printFailedResult(result);
@@ -149,10 +146,10 @@ class Reporter {
149146
console.log(`Finished in ${colors.yellow(seconds)} seconds`);
150147
}
151148

152-
_onTestStarted(testRun) {
149+
onTestRunStarted(testRun) {
153150
}
154151

155-
_onTestFinished(testRun) {
152+
onTestRunFinished(testRun) {
156153
if (this._verbose) {
157154
++this._testCounter;
158155
this._printVerboseTestRunResult(this._testCounter, testRun);

0 commit comments

Comments
 (0)