@@ -21,7 +21,7 @@ jest.mock("fs", () => ({
2121
2222describe ( "Artifact Processing Tests" , ( ) => {
2323 // Shared test data
24- let testResultsData : testResultsSummary . TestResultsData ;
24+ let testResultsData : testResultsSummary . TestResultsData | null ;
2525 let testResults : testResultsSummary . MatlabTestFile [ ] [ ] ;
2626 let stats : testResultsSummary . TestStatistics ;
2727
@@ -35,8 +35,10 @@ describe("Artifact Processing Tests", () => {
3535 copyTestDataFile ( osInfo . osName , runnerTemp , runId , actionName ) ;
3636
3737 testResultsData = testResultsSummary . getTestResults ( runnerTemp , runId , workspace ) ;
38- testResults = testResultsData . TestResults ;
39- stats = testResultsData . Stats ;
38+ if ( testResultsData ) {
39+ testResults = testResultsData . TestResults ;
40+ stats = testResultsData . Stats ;
41+ }
4042 } ) ;
4143
4244 function getOSInfo ( ) {
@@ -137,32 +139,34 @@ describe("Artifact Processing Tests", () => {
137139 } ) ;
138140
139141 it ( "should write test results data to the GitHub job summary" , ( ) => {
140- const actionName = process . env . GITHUB_ACTION || "" ;
141- testResultsSummary . writeSummary ( testResultsData , actionName ) ;
142-
143- expect ( core . summary . addHeading ) . toHaveBeenCalledTimes ( 2 ) ;
144- expect ( core . summary . addHeading ) . toHaveBeenNthCalledWith (
145- 1 ,
146- expect . stringContaining ( "MATLAB Test Results (" + actionName + ")" ) ,
147- ) ;
148- expect ( core . summary . addHeading ) . toHaveBeenNthCalledWith (
149- 1 ,
150- expect . stringContaining (
151- '<a href="https://github.com/matlab-actions/run-tests/blob/main/README.md#view-test-results"' ,
152- ) ,
153- ) ;
154- expect ( core . summary . addHeading ) . toHaveBeenNthCalledWith (
155- 1 ,
156- expect . stringContaining ( 'target="_blank"' ) ,
157- ) ;
158- expect ( core . summary . addHeading ) . toHaveBeenNthCalledWith (
159- 1 ,
160- expect . stringContaining ( "ℹ️</a>" ) ,
161- ) ;
162- expect ( core . summary . addHeading ) . toHaveBeenNthCalledWith ( 2 , "All tests" , 3 ) ;
142+ if ( testResultsData ) {
143+ const actionName = process . env . GITHUB_ACTION || "" ;
144+ testResultsSummary . writeSummary ( testResultsData , actionName ) ;
145+
146+ expect ( core . summary . addHeading ) . toHaveBeenCalledTimes ( 2 ) ;
147+ expect ( core . summary . addHeading ) . toHaveBeenNthCalledWith (
148+ 1 ,
149+ expect . stringContaining ( "MATLAB Test Results (" + actionName + ")" ) ,
150+ ) ;
151+ expect ( core . summary . addHeading ) . toHaveBeenNthCalledWith (
152+ 1 ,
153+ expect . stringContaining (
154+ '<a href="https://github.com/matlab-actions/run-tests/blob/main/README.md#view-test-results"' ,
155+ ) ,
156+ ) ;
157+ expect ( core . summary . addHeading ) . toHaveBeenNthCalledWith (
158+ 1 ,
159+ expect . stringContaining ( 'target="_blank"' ) ,
160+ ) ;
161+ expect ( core . summary . addHeading ) . toHaveBeenNthCalledWith (
162+ 1 ,
163+ expect . stringContaining ( "ℹ️</a>" ) ,
164+ ) ;
165+ expect ( core . summary . addHeading ) . toHaveBeenNthCalledWith ( 2 , "All tests" , 3 ) ;
163166
164- expect ( core . summary . addRaw ) . toHaveBeenCalledTimes ( 2 ) ;
165- expect ( core . summary . write ) . toHaveBeenCalledTimes ( 1 ) ;
167+ expect ( core . summary . addRaw ) . toHaveBeenCalledTimes ( 2 ) ;
168+ expect ( core . summary . write ) . toHaveBeenCalledTimes ( 1 ) ;
169+ }
166170 } ) ;
167171} ) ;
168172
@@ -368,17 +372,7 @@ describe("Error Handling Tests", () => {
368372
369373 try {
370374 const result = testResultsSummary . getTestResults ( process . env . RUNNER_TEMP , process . env . GITHUB_RUN_ID , "" ) ;
371-
372- // Should return empty results
373- expect ( result . TestResults ) . toEqual ( [ ] ) ;
374- expect ( result . Stats ) . toEqual ( {
375- Total : 0 ,
376- Passed : 0 ,
377- Failed : 0 ,
378- Incomplete : 0 ,
379- NotRun : 0 ,
380- Duration : 0 ,
381- } ) ;
375+ expect ( result ) . toBeNull ( ) ;
382376
383377 // Verify error was logged
384378 expect ( consoleSpy ) . toHaveBeenCalledWith (
@@ -419,9 +413,11 @@ describe("Error Handling Tests", () => {
419413 try {
420414 const result = testResultsSummary . getTestResults ( process . env . RUNNER_TEMP , process . env . GITHUB_RUN_ID , "" ) ;
421415
422- // Should still return results even if deletion fails
423- expect ( result ) . toBeDefined ( ) ;
424- expect ( result . TestResults ) . toEqual ( [ ] ) ;
416+ if ( result ) {
417+ // Should still return results even if deletion fails
418+ expect ( result ) . toBeDefined ( ) ;
419+ expect ( result . TestResults ) . toEqual ( [ ] ) ;
420+ }
425421
426422 // Verify deletion error was logged
427423 expect ( consoleSpy ) . toHaveBeenCalledWith (
0 commit comments