Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(wdio): add a browser matrix for our wdio tests #5601

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/test-wdio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ jobs:
uses: ./.github/workflows/build.yml

run_wdio:
name: Run WebdriverIO Component Tests
name: Run WebdriverIO Component Tests (${{ matrix.browser }})
runs-on: ubuntu-22.04
needs: [build_core]
strategy:
matrix:
browser: [CHROME, FIREFOX, EDGE]

steps:
- name: Checkout Code
Expand All @@ -40,6 +43,8 @@ jobs:

- name: Run WebdriverIO Component Tests
run: npm run test.wdio
env:
BROWSER: ${{ matrix.browser }}

- name: Check Git Context
uses: ./.github/workflows/actions/check-git-context
65 changes: 44 additions & 21 deletions test/wdio/wdio.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,32 @@ import type { Options } from '@wdio/types';
const __dirname = path.dirname(new URL(import.meta.url).pathname);
const isCI = Boolean(process.env.CI);

/**
* Browser usage
*
* - based on the `BROWSER` environment variable
* - if `BROWSER` is set to 'all' then we use all browsers
* - if `BROWSER` is not set, then we default to just chrome
* - if `BROWSER` is set to a browser name ('CHROME', 'FIREFOX', 'EDGE') then
* we run on that browser
*/
const BROWSER_CONFIGURATION = (() => {
switch (process.env.BROWSER) {
case 'ALL':
return 'ALL';
case 'CHROME':
return 'CHROME';
case 'FIREFOX':
return 'FIREFOX';
case 'EDGE':
return 'EDGE';
// we default to chrome in the case where the `BROWSER` env var ins't set
// to something (handy for local dev in particular)
default:
return 'CHROME';
}
})();

export const config: Options.Testrunner = {
//
// ====================
Expand Down Expand Up @@ -73,16 +99,9 @@ export const config: Options.Testrunner = {
//
maxInstances: 10,
//
// If you have trouble getting all important capabilities together, check out the
// Sauce Labs platform configurator - a great tool to configure your capabilities:
// https://saucelabs.com/platform/platform-configurator
// we set this to an empty array here and programmatically add configuration below
//
capabilities: [
{
// capabilities for local browser web tests
browserName: 'chrome', // or "firefox", "microsoftedge", "safari"
},
],
capabilities: [],

//
// ===================
Expand Down Expand Up @@ -323,16 +342,20 @@ export const config: Options.Testrunner = {
// }
};

/**
* run with more browser in CI
*/
if (isCI) {
(config.capabilities as WebdriverIO.Capabilities[]).push(
{
browserName: 'firefox',
},
{
browserName: 'edge',
},
);
if (['CHROME', 'ALL'].includes(BROWSER_CONFIGURATION)) {
(config.capabilities as WebdriverIO.Capabilities[]).push({
browserName: 'chrome',
});
}

if (['FIREFOX', 'ALL'].includes(BROWSER_CONFIGURATION)) {
(config.capabilities as WebdriverIO.Capabilities[]).push({
browserName: 'firefox',
});
}

if (['EDGE', 'ALL'].includes(BROWSER_CONFIGURATION)) {
(config.capabilities as WebdriverIO.Capabilities[]).push({
browserName: 'edge',
});
}