Returns whether or not the page text matches the given matcher
matcher(RegExporString): If given aRegExp, this is used to match against the page content. If given aString, aRegExpis created using theStringas apattern. This createdRegExpis used to match against the page content. It is important to note that this createdRegExpis 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)
})
})