Testing

Many developers use puppeteer to execute automated UI tests. However puppeteer is just a software to control Chromium and it is impossible to provide some assertion methods.

Rize provides a lot of useful assertion methods for testing. Rize is just a library and it use Node.js' assert module so you can use Rize with any testing frameworks you like.

Asserting page information

You may want to assert the URL of current page, so you can use assertUrlIs method:

rize.assertUrlIs('https://example.com/')

If you want to check the URL is matched a given regular expression, use assertUrlMatch method:

rize.assertUrlMatch(/^https?/)

Also, you can assert the query string. Just use assertQueryStringHas method:

rize.assertQueryStringHas('key')

You may want to check the query string value and not just the key:

rize.assertQueryStringHas('key', 'value')

The assertion above means check the value of key in query string. If the value does not equal to the value you gave, test will fail.

Even you can assert the query string misses a key:

rize.assertQueryStringMissing('nope')

Additionally, if you want to assert cookies, you can use assertCookieHas method.

Asserting page content and elements

Page

You can assert page title with assertTitle method or assertTitleContains method.

rize.assertTitle('page title')
rize.assertTitleContains('title')

If you want to check if the page contains expected text, just use assertSee method.

rize.assertSee('something')

You also can use assertSeeIn method to assert that expected text is in an element, and you just need to specify the selector of the element.

rize.assertSeeIn('#greeting', 'Hello!')

You can use assertDontSee or assertDontSeeIn method to assert that expected text is not in the page or element.

Elements

You can assert the state of an element:

rize.assertElementPresent('div')
rize.assertElementMissing('div')
rize.assertElementVisible('div')
rize.assertElementHidden('div')

You can check if an element contains a class:

rize.assertClassHas('#greeting', 'pull-right')

Or missing a class:

rize.assertClassMissing('#greeting', 'pull-left')

You can assert the state of a checkbox, a radio button or a dropdown:

rize.assertChecked('input[type=checkbox]')
rize.assertNotChecked('input[type=checkbox]')
rize.assertRadioSelected('input[type=radio]', 'south')
rize.assertRadioNotSelected('input[type=radio]', 'north')

And you can assert the value by using assertValueIs method or assertValueIsNot method.

Full APIs

All the assertion APIs of Rize are listed here. Those methods are prefixed with assert.