From 305e042d50db6a54d1964e77913be97b076b7b47 Mon Sep 17 00:00:00 2001 From: Rushabh Shroff Date: Wed, 30 Aug 2023 15:01:01 +0530 Subject: [PATCH] add: support for cucumber espresso tests. --- run-tests/README.md | 1 + run-tests/config/constants.js | 5 +++-- run-tests/src/utils.js | 16 +++++++++++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/run-tests/README.md b/run-tests/README.md index 0a70e1f..c591258 100644 --- a/run-tests/README.md +++ b/run-tests/README.md @@ -30,6 +30,7 @@ This action fulfils the following objectives in your runner environment: * default: * false, in case this param isn't passed reports will not be uploaded to artifacts. * specify if you want to upload test reports to artifacts. + * Note: For Espresso Cucumber Tests, please pass [plugins to your cucumberOptions](https://www.browserstack.com/docs/app-automate/espresso/run-cucumber-tests#:~:text=Step%201%3A%20Specify%20format%20of%20test%20report%20in%20command) in your config file for the report to be uploaded. > Note: In case you are using this action along with **browserstack/github-actions/upload-app@beta** you need not specify app and test_suite in the config and framework in the inputs. It will the automatically picked from the previous steps outputs. diff --git a/run-tests/config/constants.js b/run-tests/config/constants.js index 1aef7b6..1b4ca7f 100644 --- a/run-tests/config/constants.js +++ b/run-tests/config/constants.js @@ -24,8 +24,9 @@ module.exports = { xcuitest: 'xcuitest/v2/builds', }, REPORT: { - espresso: 'report', - xcuitest: 'resultbundle', + espresso_junit: 'report', + espresso_cucumber: 'assets', + xcuitest_resultbundle: 'resultbundle', }, DASHBOARD_BASE: 'app-automate.browserstack.com/dashboard/v2/builds', }, diff --git a/run-tests/src/utils.js b/run-tests/src/utils.js index b7cd8b8..dd939b6 100644 --- a/run-tests/src/utils.js +++ b/run-tests/src/utils.js @@ -180,12 +180,26 @@ class TestRunner { const rootDir = './reports'; const username = process.env[ENV_VARS.BROWSERSTACK_USERNAME].replace("-GitHubAction", ""); const accesskey = process.env[ENV_VARS.BROWSERSTACK_ACCESS_KEY]; + const inputCapabilities = content.input_capabilities; + let reportEndpoint; + if (framework === FRAMEWORKS.espresso) { + if (inputCapabilities.cucumberOptions && inputCapabilities.cucumberOptions.plugins) { + reportEndpoint = URLS.REPORT.espresso_cucumber; + } else { + reportEndpoint = URLS.REPORT.espresso_junit; + } + } else if (framework === FRAMEWORKS.xcuitest) { + reportEndpoint = URLS.REPORT.xcuitest_resultbundle; + } else { + core.error(new Error("Invalid Framework.")); + return; + } for (const device of devices) { const { sessions } = device; for (const session of sessions) { const { id } = session; const options = { - url: `https://${username}:${accesskey}@${URLS.BASE_URL}/${URLS.WATCH_FRAMEWORKS[framework]}/${buildId}/sessions/${id}/${URLS.REPORT[framework]}`, + url: `https://${username}:${accesskey}@${URLS.BASE_URL}/${URLS.WATCH_FRAMEWORKS[framework]}/${buildId}/sessions/${id}/${reportEndpoint}`, }; /* eslint-disable no-eval */ promises.push(new Promise((resolve, reject) => {