Unverified Commit 6e4f0d8e authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Use getBrowserBodyText for HMR test (#5290)

parent 7961946c
......@@ -2,7 +2,7 @@
import webdriver from 'next-webdriver'
import { readFileSync, writeFileSync, renameSync, existsSync } from 'fs'
import { join } from 'path'
import { waitFor, check } from 'next-test-utils'
import { waitFor, check, getBrowserBodyText } from 'next-test-utils'
import cheerio from 'cheerio'
export default (context, renderViaHTTP) => {
......@@ -22,7 +22,7 @@ export default (context, renderViaHTTP) => {
renameSync(contactPagePath, newContactPagePath)
await check(
() => browser.elementByCss('body').text(),
() => getBrowserBodyText(browser),
/This page could not be found/
)
......@@ -31,7 +31,7 @@ export default (context, renderViaHTTP) => {
// wait until the page comes back
await check(
() => browser.elementByCss('body').text(),
() => getBrowserBodyText(browser),
/This is the contact page/
)
} finally {
......@@ -63,7 +63,7 @@ export default (context, renderViaHTTP) => {
writeFileSync(aboutPagePath, editedContent, 'utf8')
await check(
() => browser.elementByCss('body').text(),
() => getBrowserBodyText(browser),
/COOL page/
)
......@@ -71,7 +71,7 @@ export default (context, renderViaHTTP) => {
writeFileSync(aboutPagePath, originalContent, 'utf8')
await check(
() => browser.elementByCss('body').text(),
() => getBrowserBodyText(browser),
/This is the about page/
)
} finally {
......
/* global describe, it, expect */
import webdriver from 'next-webdriver'
import { check } from 'next-test-utils'
import { check, getBrowserBodyText } from 'next-test-utils'
export default function (context) {
describe('Render via browser', () => {
......@@ -147,23 +147,21 @@ export default function (context) {
describe('pages in the nested level: level1', () => {
it('should render the home page', async () => {
const browser = await webdriver(context.port, '/')
const text = await browser
.elementByCss('#level1-home-page').click()
.waitForElementByCss('#level1-home-page')
.elementByCss('#level1-home-page p').text()
expect(text).toBe('This is the Level1 home page')
await browser.eval('document.getElementById("level1-home-page").click()')
await check(() => getBrowserBodyText(browser), /This is the Level1 home page/)
browser.close()
})
it('should render the about page', async () => {
const browser = await webdriver(context.port, '/')
const text = await browser
.elementByCss('#level1-about-page').click()
.waitForElementByCss('#level1-about-page')
.elementByCss('#level1-about-page p').text()
expect(text).toBe('This is the Level1 about page')
await browser.eval('document.getElementById("level1-about-page").click()')
await check(() => getBrowserBodyText(browser), /This is the Level1 about page/)
browser.close()
})
})
......
/* global describe, it, expect */
import webdriver from 'next-webdriver'
import { renderViaHTTP } from 'next-test-utils'
import { renderViaHTTP, getBrowserBodyText, check } from 'next-test-utils'
import cheerio from 'cheerio'
const loadJSONInPage = pageContent => {
......@@ -12,11 +12,8 @@ export default function (context) {
describe('Render in development mode', () => {
it('should render the home page', async () => {
const browser = await webdriver(context.port, '/')
const text = await browser
.elementByCss('#home-page p').text()
expect(text).toBe('This is the home page')
browser.close()
await check(() => getBrowserBodyText(browser), /This is the home page/)
})
it('should render pages only existent in exportPathMap page', async () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment