diff --git a/run-tests/src/utils.js b/run-tests/src/utils.js index dd939b6..65d288f 100644 --- a/run-tests/src/utils.js +++ b/run-tests/src/utils.js @@ -178,6 +178,9 @@ class TestRunner { core.info(`Uploading test report to artifacts for build id: ${content.id}`); const { devices, id: buildId, framework } = content; const rootDir = './reports'; + if (!fs.existsSync(rootDir)) { + fs.mkdirSync(rootDir); + } const username = process.env[ENV_VARS.BROWSERSTACK_USERNAME].replace("-GitHubAction", ""); const accesskey = process.env[ENV_VARS.BROWSERSTACK_ACCESS_KEY]; const inputCapabilities = content.input_capabilities; @@ -189,7 +192,12 @@ class TestRunner { reportEndpoint = URLS.REPORT.espresso_junit; } } else if (framework === FRAMEWORKS.xcuitest) { - reportEndpoint = URLS.REPORT.xcuitest_resultbundle; + if (inputCapabilities.enableResultBundle) { + reportEndpoint = URLS.REPORT.xcuitest_resultbundle; + } else { + core.info("'enableResultBundle' is missing in capabilities. Skipping reports."); + return; + } } else { core.error(new Error("Invalid Framework.")); return; @@ -213,9 +221,6 @@ class TestRunner { resolve(response.body); }); }).then(async (report) => { - if (!fs.existsSync(rootDir)) { - fs.mkdirSync(rootDir); - } if (framework === FRAMEWORKS.espresso) { fs.writeFileSync(`${rootDir}/${id}.xml`, report); } else if (framework === FRAMEWORKS.xcuitest) { diff --git a/run-tests/test/fixtures/build_response_xcuitest.json b/run-tests/test/fixtures/build_response_xcuitest.json index ca444b2..151faaf 100644 --- a/run-tests/test/fixtures/build_response_xcuitest.json +++ b/run-tests/test/fixtures/build_response_xcuitest.json @@ -10,7 +10,8 @@ ], "project": "SampleBuild", "app": "bs://9c6dcb5649a8280ca800075bfd8f151115bba6b3", - "testSuite": "bs://89c874f21852ba57957a3fdc33f47514288c4ba1" + "testSuite": "bs://89c874f21852ba57957a3fdc33f47514288c4ba1", + "enableResultBundle": true }, "start_time": "2020-06-04 07:43:49 UTC", "app_details": {