Commit 577cc7b6 authored by JJ Kasper's avatar JJ Kasper Committed by Joe Haddad

Fix error overlay dismiss after fixing build error (#7335)

* Make sure to dismiss type error after being fixed

* Update test
parent d7152f6a
...@@ -266,6 +266,7 @@ async function tryApplyUpdates (onHotUpdateSuccess) { ...@@ -266,6 +266,7 @@ async function tryApplyUpdates (onHotUpdateSuccess) {
} }
if (!isUpdateAvailable() || !canApplyUpdates()) { if (!isUpdateAvailable() || !canApplyUpdates()) {
ErrorOverlay.dismissBuildError()
return return
} }
......
export default () => <p>Hello world</p>
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import webdriver from 'next-webdriver' import webdriver from 'next-webdriver'
import { readFileSync, writeFileSync } from 'fs' import { readFileSync, writeFileSync } from 'fs'
import { join } from 'path' import { join } from 'path'
import { check, getBrowserBodyText } from 'next-test-utils' import { check, getBrowserBodyText, getReactErrorOverlayContent } from 'next-test-utils'
export default (context, renderViaHTTP) => { export default (context, renderViaHTTP) => {
describe('Hot Module Reloading', () => { describe('Hot Module Reloading', () => {
...@@ -13,7 +13,7 @@ export default (context, renderViaHTTP) => { ...@@ -13,7 +13,7 @@ export default (context, renderViaHTTP) => {
browser = await webdriver(context.appPort, '/hello') browser = await webdriver(context.appPort, '/hello')
await check(() => getBrowserBodyText(browser), /Hello World/) await check(() => getBrowserBodyText(browser), /Hello World/)
const pagePath = join(__dirname, '../', 'components', 'hello.ts') const pagePath = join(context.appDir, 'components', 'hello.ts')
const originalContent = readFileSync(pagePath, 'utf8') const originalContent = readFileSync(pagePath, 'utf8')
const editedContent = originalContent.replace('Hello', 'COOL page') const editedContent = originalContent.replace('Hello', 'COOL page')
...@@ -34,5 +34,27 @@ export default (context, renderViaHTTP) => { ...@@ -34,5 +34,27 @@ export default (context, renderViaHTTP) => {
} }
}) })
}) })
it('should recover from a type error', async () => {
let browser
const pagePath = join(context.appDir, 'pages/type-error-recover.tsx')
const origContent = readFileSync(pagePath, 'utf8')
try {
browser = await webdriver(context.appPort, '/type-error-recover')
const errContent = origContent.replace('() =>', '(): boolean =>')
writeFileSync(pagePath, errContent)
await check(() => getReactErrorOverlayContent(browser), /Type 'Element' is not assignable to type 'boolean'/)
writeFileSync(pagePath, origContent)
await check(async () => {
const html = await browser.eval('document.documentElement.innerHTML')
return html.match(/iframe/) ? 'fail' : 'success'
}, /success/)
} finally {
if (browser) browser.close()
writeFileSync(pagePath, origContent)
}
})
}) })
} }
...@@ -12,7 +12,8 @@ jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 5 ...@@ -12,7 +12,8 @@ jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 5
describe('TypeScript Features', () => { describe('TypeScript Features', () => {
beforeAll(async () => { beforeAll(async () => {
context.appPort = await findPort() context.appPort = await findPort()
context.server = await launchApp(join(__dirname, '../'), context.appPort) context.appDir = join(__dirname, '../')
context.server = await launchApp(context.appDir, context.appPort)
// pre-build all pages at the start // pre-build all pages at the start
await Promise.all([renderViaHTTP(context.appPort, '/hello')]) await Promise.all([renderViaHTTP(context.appPort, '/hello')])
......
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