Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wdio/browser-runner

Package Overview
Dependencies
Maintainers
3
Versions
277
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wdio/browser-runner

A WebdriverIO runner to run unit tests tests in the browser.

  • 8.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
13K
decreased by-6.99%
Maintainers
3
Weekly downloads
 
Created
Source

WebdriverIO Browser Runner

A WebdriverIO runner to run unit and component tests within the browser

As opposed to the Local Runner the Browser Runner initiates and executes the framework within the browser. This allows you to run unit tests or component tests in an actual browser rather than in a JSDOM like many other test frameworks.

While JSDOM is widely used for testing purposes, it is in the end not an actual browser nor can you emulate mobile environments with it. With this runner WebdriverIO enables you to easily run your tests in the browser and use WebDriver commands to interact with elements rendered on the page.

Here is an overview of running tests within JSDOM vs. WebdriverIOs Browser Runner

JSDOMWebdriverIO Browser Runner
1.Runs your tests within Node.js using a re-implementation of web standards, notably the WHATWG DOM and HTML StandardsExecutes your test in an actual browser and runs the code in an environment that your users use
2.Interactions with components can only be imitated via JavaScriptYou can use the WebdriverIO API to interact with elements through the WebDriver protocol
3.Canvas support requires additional dependencies and has limitationsYou have access to the real Canvas API
4.JSDOM has some caveats and unsupported Web APIsAll Web APIs are supported as test run in an actual browser
5.Impossible to detect errors cross browserSupport for all browsers including mobile browser

This runner uses Vite to compile your test code and load it in the browser. It comes with presets for the following component frameworks:

  • React
  • Preact
  • Vue.js
  • Svelte

Every test file / test file group runs within a single page which means that between each test the page is being reloaded to guarantee isolation between tests.

Install

To use the Browser Runner you can install it via:

npm install --save-dev @wdio/browser-runner

Setup

To use the Browser runner, you have to define a runner property within your wdio.conf.js file, e.g.:

// wdio.conf.js
export const {
    // ...
    runner: 'browser',
    // ...
}

If you test components using one of the mentioned frameworks above, you can define a preset that ensures everything is configured out of the box, e.g. when you want to import and test Svelte components, define the Browser Runner as follows:

// wdio.conf.js
export const {
    // ...
    runner: ['browser', {
        preset: 'Svelte'
    }],
    // ...
}

Make sure to check out the docs around component testing and have a look into the example repository for examples using these and various other frameworks.


For more information on WebdriverIO runner, check out the documentation.

Keywords

FAQs

Package last updated on 01 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc