Expect
When you're writing tests, you often need to check that values meet certain conditions. expect
gives you access to a number of "matchers" that let you validate different things on the browser
, an element
or mock
object.
Default Options
These default options below are connected to the waitforTimeout
and waitforInterval
options set in the config.
Only set the options below if you want to wait for specific timeouts for your assertions.
{
wait: 2000, // ms to wait for expectation to succeed
interval: 100, // interval between attempts
}
If you like to pick different timeouts and intervals, set these options like this:
// wdio.conf.js
import { setOptions } from 'expect-webdriverio'
export const config = {
// ...
before () {
setOptions({ wait: 5000 })
},
// ...
}
Matcher Options
Every matcher can take several options that allows you to modify the assertion:
Command Options
Name | Type | Details |
---|---|---|
wait | number | time in ms to wait for expectation to succeed. Default: 3000 |
interval | number | interval between attempts. Default: 100 |
beforeAssertion | function | function to be called before assertion is made |
afterAssertion | function | function to be called after assertion is made containing assertion results |
message | string | user message to prepend before assertion error |