# expect-webdriverio

> WebdriverIO Assertion Library

Latest version **6.0.10** (published 2026-09-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install expect-webdriverio
pnpm add expect-webdriverio
yarn add expect-webdriverio
bun add expect-webdriverio
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 6.0.10 |
| Published | 2026-09-02 |
| First published | 2019-11-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=20 |
| Dependencies | 4 |
| Unpacked size | 179 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 86 |
| Author | Mykola Grybyk |
| Maintainers | christian-bromann, wdio-user, wswebcreation-nl, willbrock, mgrybyk, klamping, abjerstedt, erwinheitzman |
| Keywords | expect-webdriverio, expect, webdriverio, wdio |

## Links

- npm: https://www.npmjs.com/package/expect-webdriverio
- Repository: https://github.com/webdriverio/expect-webdriverio
- Homepage: https://webdriver.io
- Issues: https://github.com/webdriverio/expect-webdriverio/issues
- npm.io page: https://npm.io/package/expect-webdriverio

## Dependencies (4)

- [expect](https://npm.io/package/expect.md) ^30.4.1
- [deep-eql](https://npm.io/package/deep-eql.md) ^5.0.2
- [@vitest/snapshot](https://npm.io/package/@vitest/snapshot.md) ^4.1.10
- [jest-matcher-utils](https://npm.io/package/jest-matcher-utils.md) ^30.4.1

## Recent versions

- 6.0.10 (latest) — 2026-09-02
- 4.15.4 (legacy-v4) — 2024-08-19
- 5.0.0-alpha.2 (next) — 2024-07-11
- 6.0.9 — 2026-08-24
- 6.0.8 — 2026-08-24
- 6.0.7 — 2026-08-22
- 6.0.6 — 2026-08-21
- 6.0.5 — 2026-08-17
- 6.0.4 — 2026-08-17
- 6.0.3 — 2026-08-17
- 6.0.2 — 2026-08-10
- 6.0.1 — 2026-08-06
- 6.0.0 — 2026-08-06
- 5.7.0 — 2026-06-29
- 5.6.9 — 2026-06-24
- … 134 more at https://npm.io/package/expect-webdriverio/versions

## README

# expect-webdriverio [![Test](https://github.com/webdriverio/expect-webdriverio/actions/workflows/test.yml/badge.svg)](https://github.com/webdriverio/expect-webdriverio/actions/workflows/test.yml)

###### [API](docs/API.md) | [TypeScript / JS Autocomplete](docs/Types.md) | [Examples](docs/Examples.md) | [Extending Matchers](docs/CustomMatchers.md)

> [WebdriverIO](https://webdriver.io/) assertion library inspired by [expect](https://www.npmjs.com/package/expect)

## Key Features

- [Waits](#default-options) for expectations to succeed
- Supports single element `$()` & multiple elements `$$()`
- Detailed [error messages](#error-messages)
- Works in Mocha, Cucumber, Jest, and Jasmine
- Built-in [types](docs/Types.md) for TypeScript and JS autocompletion

## Installation

1. `npm install expect-webdriverio`
2. Install your test framework adapter (if not already set up via WDIO testrunner):
   - **Mocha** (default): `npm install @wdio/mocha-framework`
   - **Jasmine**: `npm install @wdio/jasmine-framework`
   - **Cucumber**: `npm install @wdio/cucumber-framework`
   - **Jest**: No adapter needed — see [Jest Framework section](docs/Framework.md#jest)

**Note:** [WebdriverIO](https://github.com/webdriverio/webdriverio) `v9.0.0` or higher is required!

## Usage

### Using WebdriverIO Testrunner

If you run your tests through the [WDIO testrunner](https://webdriver.io/docs/clioptions), no additional setup is needed. WebdriverIO initializes `expect-webdriverio` and makes `expect` available in the global scope so you can use it directly in your tests:

```js
await expect($('button')).toBeDisplayed()
await expect($$('buttons')).toBeDisplayed()
```

See more [Examples](docs/Examples.md).

#### Local & Browser Runners
- **Local Runner**: Fully compatible. You can leverage your test framework adapter as mentioned above.
- **Browser Runner**: Designed for component frameworks like React, Preact, Vue.js, Svelte, and SolidJS, with a few known limitations. For details, see the [Browser Runner Framework section](docs/Framework.md#browser-runner).

### Using in Standalone Mode

If you use WebdriverIO in standalone mode (without `@wdio/globals`), make sure you import `expect-webdriverio` before using it anywhere.

```js
import { remote } from 'webdriverio'
import { expect } from 'expect-webdriverio'

;(async () => {
    const browser = await remote({
        capabilities: {
            browserName: 'chrome'
        }
    })

    await browser.url('https://webdriver.io')

    const $button = await browser.$('button')
    await expect($button).toBeDisplayed()
    
    await browser.deleteSession()
})().catch(console.error)
```

## API

Please see the [API documentation](docs/API.md).

## Error Messages

Error messages are informative out of the box and contain:

- Full element selector, like `$('form')`
- Actual and expected values
- Highlighted differences (text assertions)

![toHaveText](/docs/img/errors/text.png?raw=true "toHaveText")
![toHaveElementClass](/docs/img/errors/class.png?raw=true "toHaveElementClass")

## What's Next?

First of all, **feel free to raise an issue with your suggestions or help with PRs!**

### Planned

- Cookie matchers
- Multiremote support (in progress)

---
_Source: https://npm.io/package/expect-webdriverio · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
