Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@wdio/browser-runner
Advanced tools
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
JSDOM | WebdriverIO Browser Runner | |
---|---|---|
1. | Runs your tests within Node.js using a re-implementation of web standards, notably the WHATWG DOM and HTML Standards | Executes 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 JavaScript | You can use the WebdriverIO API to interact with elements through the WebDriver protocol |
3. | Canvas support requires additional dependencies and has limitations | You have access to the real Canvas API |
4. | JSDOM has some caveats and unsupported Web APIs | All Web APIs are supported as test run in an actual browser |
5. | Impossible to detect errors cross browser | Support for all browsers including mobile browser |
6. | Can not test for element pseudo states | Support for pseudo states such as :hover or :active |
This runner uses Vite to compile your test code and load it in the browser. It comes with presets for the following component frameworks:
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.
To use the Browser Runner you can install it via:
npm install --save-dev @wdio/browser-runner
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',
// ...
}
The Browser runner allows following configurations:
preset
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. This option can't be used together with viteConfig
.
Type: vue
| svelte
| solid
| react
| preact
| stencil
Example:
export const {
// ...
runner: ['browser', {
preset: 'svelte'
}],
// ...
}
viteConfig
Define your own Vite configuration. You can either pass in a custom object or import an existing vite.conf.ts
file if you use Vite.js for development. Note that WebdriverIO merges custom configurations to set up framework and runner objects. This option can't be used together with preset
.
Type: UserConfig
Example:
import viteConfig from '../vite.config.ts'
export const {
// ...
runner: ['browser', { viteConfig }],
// ...
}
headless
If set to true
the runner will update capabilities to run tests headless. By default this is enabled within CI environments where a CI
environment variable is set to '1'
or 'true'
.
Type: boolean
Default: false
, set to true
if CI
environment variable is set
rootDir
Project root directory.
Type: string
Default: process.cwd()
coverage
WebdriverIO supports test coverage reporting through istanbul
. See Coverage Options for more details.
Type: object
Default: undefined
The following options allow to configure coverage reporting.
enabled
Enables coverage collection.
Type: boolean
Default: false
include
List of files included in coverage as glob patterns.
Type: string[]
Default: [**]
exclude
List of files excluded in coverage as glob patterns.
Type: string[]
Default:
[
'coverage/**',
'dist/**',
'packages/*/test{,s}/**',
'**/*.d.ts',
'cypress/**',
'test{,s}/**',
'test{,-*}.{js,cjs,mjs,ts,tsx,jsx}',
'**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}',
'**/*{.,-}spec.{js,cjs,mjs,ts,tsx,jsx}',
'**/__tests__/**',
'**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*',
'**/.{eslint,mocha,prettier}rc.{js,cjs,yml}',
]
extension
List of file extensions the report should include.
Type: string | string[]
Default: ['.js', '.cjs', '.mjs', '.ts', '.mts', '.cts', '.tsx', '.jsx', '.vue', '.svelte']
reportsDirectory
Directory to write coverage report to.
Type: string
Default: ./coverage
reporter
Coverage reporters to use. See istanbul documentation for detailed list of all reporters.
Type: string[]
Default: ['text', 'html', 'clover', 'json-summary']
perFile
Check thresholds per file. See lines
, functions
, branches
and statements
for the actual thresholds.
Type: boolean
Default: false
clean
Clean coverage results before running tests.
Type: boolean
Default: true
lines
Threshold for lines.
Type: number
Default: undefined
functions
Threshold for functions.
Type: number
Default: undefined
branches
Threshold for branches.
Type: number
Default: undefined
statements
Threshold for statements.
Type: number
Default: undefined
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.
v9.4.4 (2024-12-19)
wdio-testingbot-service
eslint-plugin-wdio
, wdio-allure-reporter
, wdio-appium-service
, wdio-browser-runner
, wdio-browserstack-service
, wdio-cli
, wdio-config
, wdio-cucumber-framework
, wdio-firefox-profile-service
, wdio-globals
, wdio-jasmine-framework
, wdio-json-reporter
, wdio-junit-reporter
, wdio-lighthouse-service
, wdio-local-runner
, wdio-logger
, wdio-mocha-framework
, wdio-protocols
, wdio-repl
, wdio-reporter
, wdio-runner
, wdio-sauce-service
, wdio-shared-store-service
, wdio-smoke-test-cjs-service
, wdio-smoke-test-service
, wdio-spec-reporter
, wdio-static-server-service
, wdio-sumologic-reporter
, wdio-testingbot-service
, wdio-types
, wdio-utils
, wdio-webdriver-mock-service
, webdriver
, webdriverio
FAQs
A WebdriverIO runner to run unit tests tests in the browser.
The npm package @wdio/browser-runner receives a total of 10,694 weekly downloads. As such, @wdio/browser-runner popularity was classified as popular.
We found that @wdio/browser-runner demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.