@@ -17,10 +17,19 @@ describe('summaryGeneration', () => {
1717 let testResults : testResultsSummary . MatlabTestFile [ ] [ ] ;
1818 let stats : testResultsSummary . TestStatistics ;
1919
20+ let originalRunnerTemp : string | undefined ;
21+ let originalGithubRunId : string | undefined ;
22+ let originalGithubWorkspace : string | undefined ;
23+
2024 beforeAll ( ( ) => {
21- // Set environment variables before all tests
22- // process.env.RUNNER_TEMP = './';
23- // process.env.GITHUB_RUN_ID = '';
25+ // Store original values before modifying them
26+ originalRunnerTemp = process . env . RUNNER_TEMP ;
27+ originalGithubRunId = process . env . GITHUB_RUN_ID ;
28+ originalGithubWorkspace = process . env . GITHUB_WORKSPACE ;
29+
30+ // Set environment variables for tests
31+ process . env . RUNNER_TEMP = path . join ( __dirname , '..' ) ;
32+ process . env . GITHUB_RUN_ID = '' ;
2433
2534 // Get OS information and set paths
2635 const os = require ( 'os' ) . platform ( ) . toLowerCase ( ) ;
@@ -45,10 +54,10 @@ describe('summaryGeneration', () => {
4554 // Copy test data file to the expected location
4655 const artifactFileName = 'matlabTestResults.json' ;
4756 const sourceFilePath = path . join ( __dirname , 'test-data' , 'testResultsArtifacts' , 't1' , osName , artifactFileName ) ;
48- const destinationFilePath = path . join ( __dirname , '..' , artifactFileName ) ;
57+ const destinationFilePath = path . join ( process . env . RUNNER_TEMP , artifactFileName ) ;
4958 console . log ( 'Copying test data from:' , sourceFilePath ) ;
5059 console . log ( 'Copying test data to:' , destinationFilePath ) ;
51-
60+
5261 try {
5362 fs . copyFileSync ( sourceFilePath , destinationFilePath ) ;
5463 } catch ( err ) {
@@ -62,10 +71,10 @@ describe('summaryGeneration', () => {
6271 } ) ;
6372
6473 afterAll ( ( ) => {
65- // Clean up environment variables after all tests
66- // delete process.env.RUNNER_TEMP;
67- // delete process.env.GITHUB_RUN_ID;
68- delete process . env . GITHUB_WORKSPACE ;
74+ // Restore original environment variable values
75+ process . env . RUNNER_TEMP = originalRunnerTemp ;
76+ process . env . GITHUB_RUN_ID = originalGithubRunId ;
77+ process . env . GITHUB_WORKSPACE = originalGithubWorkspace ;
6978 } ) ;
7079
7180 it ( 'should return correct test results data for valid JSON' , ( ) => {
0 commit comments