How to Run WebdriverIO Tests in CI on GitHub Actions
WebdriverIO needs the app running and Chrome in headless mode; start-server-and-test wires both together.
Add --headless to the browser capabilities and use start-server-and-test to boot the app, wait for its URL, then run wdio run.
Steps
- Set headless args in the wdio capabilities.
- Install and wrap the run with
start-server-and-test. - Point
wait-onat the app URL before the suite runs. - Upload the wdio report on completion.
Workflow
.github/workflows/ci.yml
jobs:
wdio:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 20, cache: npm }
- run: npm ci
- run: npx start-server-and-test start http://localhost:3000 'wdio run wdio.conf.js'Headless capability
wdio.conf.js
export const config = {
capabilities: [{
browserName: 'chrome',
'goog:chromeOptions': {
args: ['--headless=new', '--no-sandbox', '--disable-dev-shm-usage'],
},
}],
}Gotchas
--disable-dev-shm-usageavoids Chrome crashes on the small default shared memory.start-server-and-testexits with the test command status, so a failing suite fails the job.
Related guides
How to Run Selenium Grid in CI on GitHub ActionsStand up a Selenium browser node as a GitHub Actions service container, then point your WebDriver tests at th…
How to Wait for a Server Before E2E Tests in GitHub ActionsBoot a local dev server and hold the E2E run until it responds in GitHub Actions using start-server-and-test…