Skip to content

Commit

Permalink
test(wdio): add a browser matrix for our wdio tests (#5601)
Browse files Browse the repository at this point in the history
  • Loading branch information
alicewriteswrongs authored Apr 15, 2024
1 parent ea8d29b commit 2082368
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 22 deletions.
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',
});
}

0 comments on commit 2082368

Please sign in to comment.