Nocturnal Practitioners of Magic

    expect-webdriverio
    TypeScript icon, indicating that this package has built-in type declarations

    4.1.1 • Public • Published

    expect-webdriverio

    Test

    API | TypeScript / JS Autocomplete | Examples | Extending Matchers

    WebdriverIO Assertion library inspired by expect

    Key Features

    • waits for expectation to succeed
    • detailed error messages
    • works in Mocha, Cucumber, Jest, Jasmine
    • builtin types for TypeScript and JS autocompletion

    Installation

    1. npm install expect (Jasmine and Jest users should skip this step)
    2. npm install expect-webdriverio

    NOTE: WebdriverIO v5.16.11 or higher is required!

    Usage

    Using WebdriverIO Testrunner

    If you run your tests through the WDIO testrunner no additional setup is needed. WebdriverIO initialises expect-webdriverio and makes expect available in the global scope. So you can use it directly in your tests:

    const $button = await $('button')
    await expect($button).toBeDisplayed()

    See more Examples

    Using in a standalone script

    If you embed WebdriverIO in a standalone script, make sure you import expect-webdriverio before you use it anywhere.

    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 API doc

    Error messages

    Error messages are informative out of the box and contain:

    • full element selector, like $('form').$('input')
    • actual and expected values
    • highlight the difference (texts assertions)

    toHaveText toHaveElementClass

    What's next?

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

    Planned

    • css matcher
    • size matcher
    • cookie / localStorage matchers?
    • text regex matchers
    • multiremote support (if requested)

    Install

    npm i expect-webdriverio

    Homepage

    webdriver.io

    DownloadsWeekly Downloads

    415,022

    Version

    4.1.1

    License

    MIT

    Unpacked Size

    62.7 kB

    Total Files

    48

    Last publish

    Collaborators

    • christian-bromann
    • wdio-user
    • wswebcreation-nl
    • willbrock
    • mgrybyk
    • klamping
    • abjerstedt
    • erwinheitzman