import { Allure , InMemoryAllureWriter } from "allure-js-commons" ; import { JasmineAllureReporter } from "../src/JasmineAllureReporter" ; import Env = jasmine . Env ; import { AllureWriter } from "allure-js-commons/dist/src/writers" ; export interface JasmineTestEnv extends Env { expect ( actual ) : any ; describe ( name , content ) : void ; xdescribe ( name , content ) : void ; it ( name , content ) : void ; xit ( name , content ) : void ; } export const runTest = async ( fun ) : Promise < AllureWriter > => { const writer = new InMemoryAllureWriter ( ) ; await new Promise ( ( resolve , reject ) => { const reporter = new JasmineAllureReporter ( { writer , resultsDir : "unused" } ) ; const testEnv = eval ( "new jasmine.Env()" ) ; testEnv . addReporter ( reporter ) ; testEnv . addReporter ( { jasmineDone : resolve } ) ; const testAllure = reporter . getInterface ( ) ; fun ( testEnv , testAllure ) ; testEnv . execute ( ) ; } ) ; return writer ; } ; export const delay = ( ms ) : Promise < void > => { return new Promise < void > ( function ( resolve ) { setTimeout ( resolve , ms ) ; } ) ; } ; export const delayFail = ( ms ) : Promise < void > => { return new Promise < void > ( function ( resolve , reject ) { setTimeout ( ( ) => reject ( new Error ( "Async error" ) ) , ms ) ; } ) ; } ;