Unverified Commit 2ecb7c6e authored by Joe Haddad's avatar Joe Haddad Committed by GitHub

Fix retry for Windows tests (#13296)

Noticed these tests failed for Windows on `canary`, then traced down the cause.
parent 52fd6b18
/* eslint-env jest */ /* eslint-env jest */
import cheerio from 'cheerio'
import { existsSync, readFileSync, renameSync, writeFileSync } from 'fs'
import { check, getBrowserBodyText, waitFor } from 'next-test-utils'
import webdriver from 'next-webdriver' import webdriver from 'next-webdriver'
import { readFileSync, writeFileSync, renameSync, existsSync } from 'fs'
import { join } from 'path' import { join } from 'path'
import { waitFor, check, getBrowserBodyText } from 'next-test-utils'
import cheerio from 'cheerio'
export default (context, renderViaHTTP) => { export default (context, renderViaHTTP) => {
describe('Hot Module Reloading', () => { describe('Hot Module Reloading', () => {
...@@ -79,12 +79,13 @@ export default (context, renderViaHTTP) => { ...@@ -79,12 +79,13 @@ export default (context, renderViaHTTP) => {
) )
// change the content // change the content
writeFileSync(aboutPagePath, editedContent, 'utf8') try {
writeFileSync(aboutPagePath, editedContent, 'utf8')
await check(() => getBrowserBodyText(browser), /COOL page/) await check(() => getBrowserBodyText(browser), /COOL page/)
} finally {
// add the original content // add the original content
writeFileSync(aboutPagePath, originalContent, 'utf8') writeFileSync(aboutPagePath, originalContent, 'utf8')
}
await check( await check(
() => getBrowserBodyText(browser), () => getBrowserBodyText(browser),
...@@ -124,18 +125,16 @@ export default (context, renderViaHTTP) => { ...@@ -124,18 +125,16 @@ export default (context, renderViaHTTP) => {
'COOL page' 'COOL page'
) )
// Change the about.js page try {
writeFileSync(aboutPagePath, editedContent, 'utf8') // Change the about.js page
writeFileSync(aboutPagePath, editedContent, 'utf8')
// wait for 5 seconds
await waitFor(5000)
// Check whether the this page has reloaded or not.
const newText = await browser.elementByCss('p').text()
expect(newText).toBe('COUNT: 2')
// restore the about page content. // Check whether the this page has reloaded or not.
writeFileSync(aboutPagePath, originalContent, 'utf8') await check(() => browser.elementByCss('p').text(), /COUNT: 2/)
} finally {
// restore the about page content.
writeFileSync(aboutPagePath, originalContent, 'utf8')
}
} finally { } finally {
if (browser) { if (browser) {
await browser.close() await browser.close()
......
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