()
| 38 | |
| 39 | // tslint:disable: no-console |
| 40 | public static async run() { |
| 41 | chalk.level = 3; |
| 42 | try { |
| 43 | // We tell the runner to start running at the end of current block of |
| 44 | // synchronously executed code. This will typically be after all the |
| 45 | // suite definitions are evaluated. This is equivalent to setTimeout(..., 0). |
| 46 | await promisify(process.nextTick)(); |
| 47 | const ctx: IRunContext = { |
| 48 | // tslint:disable-next-line: tsr-detect-non-literal-regexp |
| 49 | testNameMatcher: new RegExp(process.env.TESTBRIDGE_TEST_ONLY) || /.*/, |
| 50 | path: [], |
| 51 | results: [], |
| 52 | beforeEaches: [], |
| 53 | afterEaches: [] |
| 54 | }; |
| 55 | |
| 56 | await Promise.all([...this.topLevelSuites].map(suite => suite.run(ctx))); |
| 57 | |
| 58 | for (const result of ctx.results) { |
| 59 | const outcomeString = (result.outcome || "unknown").toUpperCase(); |
| 60 | const pathString = result.path.join(" > "); |
| 61 | |
| 62 | const colorFn = |
| 63 | result.outcome === "failed" || result.outcome === "timeout" |
| 64 | ? chalk.red |
| 65 | : result.outcome === "passed" |
| 66 | ? chalk.green |
| 67 | : chalk.yellow; |
| 68 | if (pathString.length + outcomeString.length + 1 <= 80) { |
| 69 | console.info( |
| 70 | `${pathString}${new Array(80 - pathString.length - outcomeString.length - 1) |
| 71 | .fill(" ") |
| 72 | .join("")}${colorFn(outcomeString)}` |
| 73 | ); |
| 74 | } else { |
| 75 | console.info(pathString); |
| 76 | console.info( |
| 77 | `${new Array(80 - outcomeString.length - 1).fill(" ").join("")}${colorFn( |
| 78 | outcomeString |
| 79 | )}` |
| 80 | ); |
| 81 | } |
| 82 | |
| 83 | if (result.err) { |
| 84 | const errString = result.err.stack |
| 85 | ? result.err.stack && this.indent(result.err.stack as string) |
| 86 | : ` ${DeterministicStringify(result.err, { space: " " })}`; |
| 87 | |
| 88 | console.error(`\n${errString}\n`); |
| 89 | if (result.err.showDiff) { |
| 90 | this.logExpectedVsActual(result); |
| 91 | } |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | const hasErrors = ctx.results.some(result => result.outcome !== "passed"); |
| 96 | |
| 97 | if (hasErrors) { |
no test coverage detected