The Assert Wrapper – the Importance of Embedded Details
In this chapter, we will be writing our first assertion wrapper. Assertions allow us to pass or fail a test as well as add detail regarding the expected and actual results. WebdriverIO has at least three ways to implement assertions and each has its own style. First, there is the standard Jest expect assertion library, which is basic to evaluate numbers, strings, and even regular expression matchers. Then there is the expect-webdriverio assertion library, which is an extension of the Jest matchers. These take web objects and perform assertions on both values and states. Lastly, there is the Chai assertion library, which provides soft assertions and a variety of implementation styles. While the library choice is up to you, we will be using expect-webdriverio
for all examples in this book. However, a little background on how these approaches differ should be noted.
We'll cover the following main topics in this chapter...