-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from wolframkriesing/make-reporter-have-pass-a…
…nd-fail Make reporter have `pass()` and `fail()`, no more `oneStep()`.
- Loading branch information
Showing
6 changed files
with
59 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,23 @@ | ||
const testDescription = (specs, description) => { | ||
const allSpecs = specs.join(' '); | ||
return (allSpecs ? allSpecs + ' ' : allSpecs) + description; | ||
}; | ||
|
||
export class Console { | ||
constructor(reporter = console) { | ||
this._print = (...args) => reporter.log(...args); | ||
} | ||
fail(errorMessage) { | ||
this._print(errorMessage); | ||
} | ||
final(failures, passes, elapsedTime) { | ||
this._print(`${failures} failed, ${passes} succeeded in ${elapsedTime.toFixed(2)}ms`); | ||
} | ||
oneStep(specs, description, result, elapsedTime) { | ||
const allSpecs = specs.join(' '); | ||
const testDesc = (allSpecs ? allSpecs + ' ' : allSpecs) + description; | ||
|
||
const successSign = '✓'; | ||
fail(specs, description, errorMessage, elapsedTime) { | ||
const testDesc = testDescription(specs, description); | ||
const failureSign = 'x'; | ||
const sign = result ? successSign : failureSign; | ||
this._print(`${testDesc} => ${sign} in ${elapsedTime.toFixed(2)}ms`); | ||
this._print(`${testDesc} => ${failureSign} in ${elapsedTime.toFixed(2)}ms\n${errorMessage}`); | ||
} | ||
pass(specs, description, elapsedTime) { | ||
const testDesc = testDescription(specs, description); | ||
const successSign = '✓'; | ||
this._print(`${testDesc} => ${successSign} in ${elapsedTime.toFixed(2)}ms`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters