Returns whether or not the page text matches the given matcher
matcher
(RegExp
orString
): If given aRegExp
, this is used to match against the page content. If given aString
, aRegExp
is created using theString
as apattern
. This createdRegExp
is used to match against the page content. It is important to note that this createdRegExp
is case sensitive.
true
or false
depending on whether the RegExp
matcher matches against the
return value of .content() => String
.
import React from 'react'
import Page from 'react-page-object'
const App = () => <h1>My App</h1>
describe('contentMatches', () => {
let page
beforeEach(() => {
page = new Page(<App />)
})
afterEach(() => {
page.destroy()
})
it('returns true if content matches - RegExp given', () => {
expect(page.contentMatches(/My App/)).toBe(true)
})
it('returns true if content matches - string given', () => {
expect(page.contentMatches('My App')).toBe(true)
})
it('returns false if content does not match', () => {
expect(page.contentMatches(/should not match/)).toBe(false)
})
})