Skip to content

Commit

Permalink
feat(testrunner): migrate from events to a delegate (#1647)
Browse files Browse the repository at this point in the history
This allows an async handler for each event that can be awaited.
Drive-by: merge TestPass into TestRunner.
  • Loading branch information
dgozman committed Apr 3, 2020
1 parent f216ab9 commit 823f961
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 148 deletions.
13 changes: 5 additions & 8 deletions utils/testrunner/Reporter.js
Expand Up @@ -33,13 +33,10 @@ class Reporter {
this._verbose = verbose;
this._summary = summary;
this._testCounter = 0;
runner.on('started', this._onStarted.bind(this));
runner.on('finished', this._onFinished.bind(this));
runner.on('teststarted', this._onTestStarted.bind(this));
runner.on('testfinished', this._onTestFinished.bind(this));
runner.setDelegate(this);
}

_onStarted(testRuns) {
onStarted(testRuns) {
this._testCounter = 0;
this._timestamp = Date.now();
const allTests = this._runner.tests();
Expand Down Expand Up @@ -83,7 +80,7 @@ class Reporter {
console.log('');
}

_onFinished(result) {
onFinished(result) {
this._printTestResults(result);
if (!result.ok())
this._printFailedResult(result);
Expand Down Expand Up @@ -149,10 +146,10 @@ class Reporter {
console.log(`Finished in ${colors.yellow(seconds)} seconds`);
}

_onTestStarted(testRun) {
onTestRunStarted(testRun) {
}

_onTestFinished(testRun) {
onTestRunFinished(testRun) {
if (this._verbose) {
++this._testCounter;
this._printVerboseTestRunResult(this._testCounter, testRun);
Expand Down

0 comments on commit 823f961

Please sign in to comment.