license import { Reporter } from '../reporter.js' ; import { TestResult } from '../test.js' ; export interface SpecResult { testResults : TestResult [ ] ; } export interface SuiteResult { specResults : SpecResult [ ] ; } /**
 * TestReporter provides a Reporter that accumulates test results
 * from a Suite run into the `results` property as an array.
 *
 * This is intended to be used for testing mixins that modify test results.
 */ export class TestReporter extends Reporter { suiteResult : SuiteResult = { specResults : [ ] } ; /**
     * An array of test results from the Suite run.
     * Example:
     * ```js
     * const reporter = new TestReporter();
     * const suite = new Suite([spec], reporter);
     * await suite.run();
     * console.log(reporter.results);
     * ```
     */ get results ( ) : TestResult [ ] { const results = [ ] ; for ( const spec of this . suiteResult . specResults ) { for ( const test of spec . testResults ) { results . push ( test ) ; } } return results ; } onSpecStart ( ) { this . suiteResult . specResults . push ( { testResults : [ ] } ) ; } onTestEnd ( result ) { const srs = this . suiteResult . specResults ; const spec = srs [ srs . length - 1 ] ; spec . testResults . push ( result ) ; } }