import { expect } from '../../lib/assertion/expect' ; import { CompositeReport } from '../../lib/reporting/report/compositeReport' ; import { FailedTestReport } from '../../lib/reporting/report/failedTestReport' ; import { LeafReport } from '../../lib/reporting/report/leafReport' ; import { Report } from '../../lib/reporting/report/report' ; import { TestSuiteInstance } from '../../lib/tests/testSuite' ; export class TestUtils { public static getInstance ( testClass ) { return testClass . __testSuiteInstance ; } public static expectReportsToBeEqual ( actualReport , expectedReport ) { this . expectSameType ( actualReport , expectedReport ) ; expect . toBeEqual ( actualReport . result , expectedReport . result ) ; expect . toBeEqual ( actualReport . name , expectedReport . name ) ; if ( actualReport instanceof FailedTestReport ) { expect . toBeEqual ( actualReport . message , ( expectedReport as FailedTestReport ) . message ) ; } if ( actualReport instanceof LeafReport ) { return ; } const actualChildren = ( actualReport as CompositeReport ) . getChildren ( ) ; const expectedChildren = ( expectedReport as CompositeReport ) . getChildren ( ) ; for ( const i in actualChildren ) { if ( ! actualChildren . hasOwnProperty ( i ) ) { continue ; } this . expectReportsToBeEqual ( actualChildren [ i ] , expectedChildren [ i ] ) ; } } public static expectSameType ( actualReport , expectedReport ) { return expect . toBeEqual ( actualReport . constructor , expectedReport . constructor ) ; } }