import * as core from '@actions/core' ; import * as cmakeaction from '../src/cmake-action' ; import * as runcmakelib from '@lukka/run-cmake-lib' ; jest . setTimeout ( 15 * 1000 ) ; jest . mock ( "@lukka/run-cmake-lib" ) ; describe ( 'run-cmake unit tests' , ( ) => { test ( 'run without exception' , async ( ) => { await cmakeaction . main ( ) ; } ) ; test ( 'run with exception, it must fail' , async ( ) => { const setFailedMock = jest . spyOn ( core , "setFailed" ) ; jest . spyOn ( runcmakelib . CMakeRunner , "run" ) . mockImplementation ( ( ) => { throw new Error ( ) ; } ) ; await cmakeaction . main ( ) ; expect ( setFailedMock ) . toBeCalledTimes ( 1 ) ; } ) ; } ) ;