import * as childProcess from "child_process" ; export async function closeWorkbook ( ) { try { await Excel . run ( async ( context ) => { context . workbook . close ( Excel . CloseBehavior . skipSave ) ; Promise . resolve ( ) ; } ) ; } catch ( err ) { Promise . reject ( `Error on closing workbook: ${ err }` ) ; } } export function addTestResult ( testValues , resultName , resultValue , expectedValue ) { var data = { } ; data [ "expectedValue" ] = expectedValue ; data [ "resultName" ] = resultName ; data [ "resultValue" ] = resultValue ; testValues . push ( data ) ; } export async function closeDesktopApplication ( ) { const processName = "Excel" ; try { let appClosed = false ; if ( process . platform == "win32" ) { const cmdLine = `tskill ${ processName }` ; appClosed = await executeCommandLine ( cmdLine ) ; } return appClosed ; } catch ( err ) { throw new Error ( `Unable to kill excel process. ${ err }` ) ; } } async function executeCommandLine ( cmdLine ) { return new Promise < boolean > ( ( resolve , reject ) => { childProcess . exec ( cmdLine , ( error ) => { if ( error ) { reject ( false ) ; } else { resolve ( true ) ; } } ) ; } ) ; } export async function sleep ( ms ) { return new Promise ( ( resolve ) => setTimeout ( resolve , ms ) ) ; }