Unverified Commit c731d591 authored by Joe Haddad's avatar Joe Haddad Committed by GitHub

Fix AMP Test Flake (#13450)

Observed here: https://github.com/zeit/next.js/pull/13434#issuecomment-634566450
parent 710997d4
/* eslint-env jest */ /* eslint-env jest */
import { join } from 'path'
import cheerio from 'cheerio'
import webdriver from 'next-webdriver'
import { validateAMP } from 'amp-test-utils' import { validateAMP } from 'amp-test-utils'
import cheerio from 'cheerio'
import { import {
accessSync, accessSync,
readFile,
readFileSync, readFileSync,
writeFileSync,
writeFile, writeFile,
readFile, writeFileSync,
} from 'fs-extra' } from 'fs-extra'
import { import {
waitFor,
nextServer,
nextBuild,
startApp,
stopApp,
renderViaHTTP,
check, check,
getBrowserBodyText,
findPort, findPort,
launchApp, getBrowserBodyText,
killApp, killApp,
launchApp,
nextBuild,
nextServer,
renderViaHTTP,
startApp,
stopApp,
waitFor,
} from 'next-test-utils' } from 'next-test-utils'
import webdriver from 'next-webdriver'
import { join } from 'path'
const appDir = join(__dirname, '../') const appDir = join(__dirname, '../')
let appPort let appPort
...@@ -451,8 +451,7 @@ describe('AMP Usage', () => { ...@@ -451,8 +451,7 @@ describe('AMP Usage', () => {
it('should detect changes to component and refresh an AMP page', async () => { it('should detect changes to component and refresh an AMP page', async () => {
const browser = await webdriver(dynamicAppPort, '/hmr/comp') const browser = await webdriver(dynamicAppPort, '/hmr/comp')
const text = await browser.elementByCss('#hello-comp').text() await check(() => browser.elementByCss('#hello-comp').text(), /hello/)
expect(text).toBe('hello')
const testComp = join(__dirname, '../components/hello.js') const testComp = join(__dirname, '../components/hello.js')
...@@ -472,10 +471,9 @@ describe('AMP Usage', () => { ...@@ -472,10 +471,9 @@ describe('AMP Usage', () => {
await renderViaHTTP(dynamicAppPort, '/hmr/test') await renderViaHTTP(dynamicAppPort, '/hmr/test')
browser = await webdriver(dynamicAppPort, '/hmr/amp') browser = await webdriver(dynamicAppPort, '/hmr/amp')
const text = await browser.elementByCss('p').text() await check(() => browser.elementByCss('p').text(), /I'm an AMP page!/)
const origDate = await browser.elementByCss('span').text()
expect(text).toBe(`I'm an AMP page!`)
const origDate = await browser.elementByCss('span').text()
const hmrTestPagePath = join( const hmrTestPagePath = join(
__dirname, __dirname,
'../', '../',
......
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