8.36.1 • Published 3 days ago

@wdio/browser-runner v8.36.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 days ago

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
6.Can not test for element pseudo statesSupport 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:

  • React
  • Preact
  • Vue.js
  • Svelte
  • SolidJS

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',
    // ...
}

Runner Options

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

Coverage Options

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

Examples

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.

9.0.0-alpha.113

3 days ago

9.0.0-alpha.114

3 days ago

9.0.0-alpha.115

3 days ago

8.36.1

9 days ago

8.36.0

16 days ago

9.0.0-alpha.78

20 days ago

9.0.0-alpha.59

1 month ago

9.0.0-alpha.64

1 month ago

8.35.0

1 month ago

8.35.1

1 month ago

8.34.0

1 month ago

8.34.1

1 month ago

9.0.0-alpha.9

1 month ago

9.0.0-alpha.0

2 months ago

8.33.1

2 months ago

8.33.0

2 months ago

8.32.4

2 months ago

8.32.3

2 months ago

8.32.2

2 months ago

8.32.1

2 months ago

8.32.0

2 months ago

8.31.1

3 months ago

8.31.0

3 months ago

8.30.0

3 months ago

8.29.7

3 months ago

8.29.5

3 months ago

8.29.6

3 months ago

8.29.3

3 months ago

8.29.2

3 months ago

8.29.1

3 months ago

8.29.0

3 months ago

8.28.8

3 months ago

8.28.6

3 months ago

8.28.7

3 months ago

8.28.4

3 months ago

8.28.5

3 months ago

8.28.3

3 months ago

8.28.0

3 months ago

8.28.1

3 months ago

8.27.2

4 months ago

8.27.0

4 months ago

8.26.3

4 months ago

8.26.2

4 months ago

8.26.1

5 months ago

8.26.0

5 months ago

8.25.0

5 months ago

8.26.1-alpha.1

5 months ago

8.24.13

5 months ago

8.24.9

5 months ago

8.24.12

5 months ago

8.16.16

7 months ago

8.16.17

7 months ago

8.16.18

7 months ago

8.16.19

7 months ago

8.16.10

8 months ago

8.11.3

10 months ago

8.16.11

7 months ago

8.16.12

7 months ago

8.15.1

9 months ago

8.15.0

9 months ago

8.16.14

7 months ago

8.16.15

7 months ago

8.15.2

9 months ago

8.22.0

6 months ago

8.22.1

6 months ago

8.16.20

7 months ago

8.16.22

7 months ago

8.19.0

6 months ago

8.15.4

9 months ago

8.15.7

8 months ago

8.15.6

8 months ago

8.15.9

8 months ago

8.15.8

8 months ago

8.12.2

10 months ago

8.12.1

10 months ago

8.16.0

8 months ago

8.12.3

10 months ago

8.16.2

8 months ago

8.24.6

5 months ago

8.13.13

9 months ago

8.23.0

6 months ago

8.23.1

5 months ago

8.23.2

5 months ago

8.23.3

5 months ago

8.13.10

9 months ago

8.23.4

5 months ago

8.23.5

5 months ago

8.13.12

9 months ago

8.13.11

9 months ago

8.16.4

8 months ago

8.16.3

8 months ago

8.16.6

8 months ago

8.16.5

8 months ago

8.16.7

8 months ago

8.16.9

8 months ago

8.13.1

10 months ago

8.13.0

10 months ago

8.13.3

10 months ago

8.13.2

10 months ago

8.17.0

7 months ago

8.13.4

10 months ago

8.20.0

6 months ago

8.20.3

6 months ago

8.24.0

5 months ago

8.20.4

6 months ago

8.24.1

5 months ago

8.20.5

6 months ago

8.15.10

8 months ago

8.24.2

5 months ago

8.24.3

5 months ago

8.24.4

5 months ago

8.24.5

5 months ago

8.13.7

9 months ago

8.13.6

9 months ago

8.13.9

9 months ago

8.13.8

9 months ago

8.14.0

9 months ago

8.14.2

9 months ago

8.14.1

9 months ago

8.18.0

7 months ago

8.14.3

9 months ago

8.21.0

6 months ago

8.18.2

7 months ago

8.14.6

9 months ago

8.11.2

11 months ago

8.11.1

11 months ago

8.11.0

11 months ago

8.10.7

11 months ago

8.10.6

11 months ago

8.10.5

11 months ago

8.10.4

11 months ago

8.10.2

12 months ago

8.10.1

12 months ago

8.10.0

12 months ago

8.9.0

12 months ago

8.8.8

1 year ago

8.8.7

1 year ago

8.8.6

1 year ago

8.8.5

1 year ago

8.8.4

1 year ago

8.8.2

1 year ago

8.8.1

1 year ago

8.8.0

1 year ago

8.7.0

1 year ago

8.6.9

1 year ago

8.6.8

1 year ago

8.6.7

1 year ago

8.6.6

1 year ago

8.6.3

1 year ago

8.6.2

1 year ago

8.6.1

1 year ago

8.6.0

1 year ago

8.5.9

1 year ago

8.5.8

1 year ago

8.5.7

1 year ago

8.5.6

1 year ago

8.5.5

1 year ago

8.5.4

1 year ago

8.5.3

1 year ago

8.5.2

1 year ago

8.5.1

1 year ago

8.5.0

1 year ago

8.4.0

1 year ago

8.3.11

1 year ago

8.3.10

1 year ago

8.3.9

1 year ago

8.3.8

1 year ago

8.3.7

1 year ago

8.3.6

1 year ago

8.3.5

1 year ago

8.3.4

1 year ago

8.3.3

1 year ago

8.3.2

1 year ago

8.3.1

1 year ago

8.3.0

1 year ago

8.2.6

1 year ago

8.2.4

1 year ago

8.2.3

1 year ago

8.2.2

1 year ago

8.2.1

1 year ago

8.2.0

1 year ago

8.1.3

1 year ago

8.1.2

1 year ago

8.1.0

1 year ago

8.0.15

1 year ago

8.0.14

1 year ago

8.0.13

1 year ago

8.0.12

1 year ago

8.0.11

1 year ago

8.0.10

1 year ago

8.0.9

1 year ago

8.0.8

1 year ago

8.0.7

1 year ago

8.0.6

1 year ago

8.0.5

1 year ago

8.0.4

1 year ago

8.0.3

1 year ago

8.0.2

1 year ago

8.0.1

1 year ago

8.0.0

1 year ago

8.0.0-alpha.631

1 year ago

8.0.0-alpha.630

1 year ago

8.0.0-alpha.629

1 year ago

8.0.0-alpha.621

1 year ago

8.0.0-alpha.620

1 year ago

8.0.0-alpha.619

1 year ago

8.0.0-alpha.607

1 year ago

8.0.0-alpha.600

1 year ago

8.0.0-alpha.598

1 year ago

8.0.0-alpha.593

1 year ago

8.0.0-alpha.589

1 year ago

8.0.0-alpha.577

1 year ago

8.0.0-alpha.565

1 year ago

8.0.0-alpha.563

1 year ago

8.0.0-alpha.558

1 year ago

8.0.0-alpha.547

1 year ago

8.0.0-alpha.537

1 year ago

8.0.0-alpha.518

1 year ago

8.0.0-alpha.516

1 year ago

8.0.0-alpha.512

1 year ago

8.0.0-alpha.508

1 year ago

8.0.0-alpha.507

1 year ago

8.0.0-alpha.505

1 year ago

8.0.0-alpha.504

1 year ago