October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk7 min

How to Run Component Tests with WebdriverIO

Set up WebdriverIO’s Browser Runner to render components in a real browser, interact with them using WebDriver commands, and run reliable component tests.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use WebdriverIO’s Browser Runner to render components in a real browser, interact with them through WebDriver commands, and assert on the result. Start the setup wizard with npm init wdio@latest ./, choose the browser runner, configure the preset and test utilities for your framework, then run the suite with npx wdio run ./wdio.conf.js.

What WebdriverIO component tests do

The Browser Runner uses Vite to compile test code and load a test page in an actual desktop or mobile browser. A framework rendering utility mounts the component into that page; WebdriverIO commands then interact with the rendered elements through the browser automation interface. This gives tests access to browser behavior that a DOM emulation may not reproduce, but it tests components in the runner’s page—not the whole deployed application or all of its integrations. WebdriverIO component testing overview and Browser Runner reference.

Set up the Browser Runner

  1. In the project directory, run the official setup wizard:

    npm init wdio@latest ./

  2. Select browser as the runner. Choose the preset for your framework if offered; choose Other for basic browser-based unit tests. If the project already uses Vite, reuse its configuration when appropriate.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  3. Review the generated WDIO configuration. Confirm the runner choice, framework preset, Vite setup, and browser options match your project; do not assume the wizard’s defaults fit every build.

  4. Install the framework’s required Vite plugin and any rendering or query utility you plan to use. The framework guides include their package setup and configuration examples.

The documented presets include React, Preact, Vue, Svelte, SolidJS, and Stencil. You can also provide a custom Vite configuration or refer to an existing one; the runner adapts custom Vite configuration to set up its test harness. See the component-testing overview and the framework guides for React, Vue, and Preact.

Framework presets and Vite plugins

Framework Runner preset or setup detail Documented Vite plugin
React preset: 'react' @vitejs/plugin-react
Vue preset: 'vue' @vitejs/plugin-vue
Preact Preact preset @preact/preset-vite
Svelte, SolidJS, Stencil Documented presets are available Check the applicable framework guide for its setup
Other or custom setup Choose Other for basic browser-based tests, or configure custom/existing Vite Depends on the project’s Vite setup

These are the framework options documented in the WebdriverIO component-testing guides retrieved on October 3, 2026; preset support and package requirements can change. Confirm the current instructions in the relevant guide before upgrading or setting up a new project.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Render, interact, and assert

Testing Library can render a component into the test page, provide accessible queries, and clean rendered components up between tests. WebdriverIO commands are useful for browser interactions such as clicking. If you render without a helper that handles cleanup, arrange to remove the component or clear its test container between tests.

React example

The following follows the documented React pattern: render a component, locate its button by accessible role and name, click it with WebdriverIO, then check the updated page content.

Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option
import { render, screen } from '@testing-library/react';
import Counter from './Counter.jsx';

describe('Counter', () => {
  it('increments when clicked', async () => {
    render(<Counter />);

    const button = screen.getByRole('button', { name: /increment/i });
    await button.click();

    expect(screen.getByText('Count: 1')).toBeDisplayed();
  });
});

Adapt the component import, accessible name, and expected text to your own component. Install @testing-library/react as a development dependency if you use this helper. See the official React component-testing guide for its current complete example and setup.

Vue rendering choices

For Vue, the official examples use either @vue/test-utils or @testing-library/vue to render the component, then WebdriverIO commands to exercise browser interactions. Choose the helper that matches how you want to mount and query components; whichever you use, ensure rendered state is cleaned up or isolated as intended. Follow the Vue guide for imports and configuration specific to your project.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Run tests locally and in CI

Run the generated configuration from the project root:

npx wdio run ./wdio.conf.js

This is the invocation used by the official React and Vue examples. In CI, the Browser Runner defaults to headless mode when the environment variable CI is set to '1' or 'true'. The runner’s headless option controls that behavior; inspect the generated configuration if your CI environment uses a different value or you need to override the default. Runner reference.

Watch and debug

Use the documented --watch option to rerun changed files during development. The debug command can stop execution and open a Node.js REPL while you inspect the browser. IDE breakpoints are not yet recognized in the remote browser according to the runner guide, so use the documented debug workflow rather than assuming browser-side breakpoints will pause the test.

Remote Selenium Grid

If the browser runs through Selenium Grid, configure the Browser Runner’s host so the remote browser can reach the machine that serves the test files. A browser that cannot reach that host may fail before the component test begins; check network reachability from the remote browser as well as the local WDIO process. See the runner reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Isolation and limits to account for

Test isolation

The runner reference says each test file or group runs within one page, and the page reloads between tests to provide isolation. Rendering helpers can still be useful for consistent mounting and cleanup within a test. Avoid relying on state surviving from one test to another.

Test framework support

The component-testing overview identifies Mocha as the supported framework and describes Jasmine and Cucumber as roadmap items. This support detail is version-sensitive; check the current overview before adopting a different framework.

Native blocking dialogs

Native thread-blocking dialogs such as alert and confirm cannot be used normally because they block communication with the page. The runner supplies mocks with default return values. If the component’s behavior depends on a particular dialog response, mock the relevant API explicitly in the test rather than treating the default as the behavior under test. See the runner reference.

Nuxt and application context

The Vue guide describes support for Nuxt composables and pages with caveats. Modules that require a Nuxt application context cannot be initialized solely in the browser and should generally be tested as end-to-end behavior; third-party composables may need manual mocks. If the behavior depends on app-level wiring, routing, server behavior, or integrations rather than the component in isolation, use an appropriate end-to-end test as well. See the Vue guide.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Troubleshoot common setup failures

  • The runner does not start in a browser: Check the generated WDIO configuration and make sure the wizard was set to the browser runner, not another runner type.

  • Framework files or JSX fail to compile: Verify that the selected preset matches the framework and that its required Vite plugin is installed and configured. React uses @vitejs/plugin-react; Vue uses @vitejs/plugin-vue; the documented Preact setup uses @preact/preset-vite.

    Rank #4
    Sale
    Web Design with HTML, CSS, JavaScript and jQuery Set
    • Brand: Wiley
    • Set of 2 Volumes
    • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
  • Elements cannot be found after mounting: Confirm the render helper has mounted the component into the runner’s test page and that the query matches the rendered accessible role, name, or text. Check whether the component renders asynchronously before querying it.

  • Tests leak state or affect one another: Use a rendering helper that cleans up, or implement cleanup for your own test container. Remember the runner’s page reload isolation applies between tests, not as a substitute for correct setup and teardown within a test.

    What’s actually slowing this PC down?

    Pick the symptom - the matching free tool is one click away.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • A test hangs around alert or confirm: These blocking dialogs interfere with page communication. Explicitly mock the dialog API and return value needed for the behavior being tested.

  • A Grid browser cannot load test assets: Set the runner’s host so the remote browser can reach the host serving the test files, then verify connectivity from that browser’s network.

  • Nuxt code fails without app context: Determine whether the composable or module requires Nuxt initialization unavailable in the browser component runner. Mock third-party composables where suitable, or move app-context and integrated behavior to end-to-end coverage.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Performance, reliability, and choosing the right test boundary

Browser component tests execute in a real browser, so they exercise browser APIs and WebDriver interactions rather than only a simulated DOM. That fidelity is useful when component behavior depends on actual browser behavior; it is not evidence that the full application works after deployment. Keep component tests focused on rendered component behavior, and cover routing, server integration, and application-wide flows with end-to-end tests where those are in scope.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For reliable runs, keep tests independent, use the documented page isolation, and make CI’s headless behavior explicit in the runner configuration when its environment differs from the documented CI values. For remote execution, ensure the browser can reach the test-file host. The cited documentation does not establish a general execution-time or resource-use benchmark, so choose local versus Grid execution based on your project’s infrastructure and verify it in your own CI environment.

Or skip the browser setup

WebdriverIO runs component tests in a browser; ScreenshotNeo is for taking website screenshots, not a replacement for component-test assertions. If your task is to capture a page rather than test component behavior, a single request can return an image. See the ScreenshotNeo website and API documentation.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo accepts consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, with response headers identifying the page verdict and billing status. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for AI agents. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 screenshots.

Sign up for ScreenshotNeo’s free plan to try 1,000 screenshots a month with no card.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently Asked Questions

Does WebdriverIO component testing replace end-to-end testing?

No. It tests rendered components in the Browser Runner’s test page; integrated application flows still need appropriate end-to-end coverage.

Can I use WebdriverIO’s Browser Runner with a project that already uses Vite?

Yes. The setup can reuse a suitable existing Vite configuration or use a custom one; review the generated WDIO configuration and runner documentation.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.