Skip to content

Files

Latest commit

 

History

History
48 lines (35 loc) · 980 Bytes

content.md

File metadata and controls

48 lines (35 loc) · 980 Bytes

.content() => String

Returns the page text

Returns

A string containing all the text in the page. Please note that this does not include text inside input fields since these are actually HTML attributes.

Related Methods

Example in Jest

import React from 'react'
import Page from 'react-page-object'

const App = () => (
  <div>
    <h1>My App</h1>
    <input value="this does not show up" readOnly />
  </div>
)

describe('content', () => {
  let page

  beforeEach(() => {
    page = new Page(<App />)
  })

  afterEach(() => {
    page.destroy()
  })

  it('returns page text', () => {
    expect(page.content()).toMatch(/My App/)
    expect(page.content()).not.toMatch(/this does not show up/)
  })

  it('does not contain text inside input fields', () => {
    expect(page.content()).not.toMatch(/this does not show up/)
  })
})