提交 577cc7b6 编写于 作者: J JJ Kasper 提交者: Joe Haddad

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

* Make sure to dismiss type error after being fixed

* Update test
上级 d7152f6a
......@@ -266,6 +266,7 @@ async function tryApplyUpdates (onHotUpdateSuccess) {
}
if (!isUpdateAvailable() || !canApplyUpdates()) {
ErrorOverlay.dismissBuildError()
return
}
......
......@@ -2,7 +2,7 @@
import webdriver from 'next-webdriver'
import { readFileSync, writeFileSync } from 'fs'
import { join } from 'path'
import { check, getBrowserBodyText } from 'next-test-utils'
import { check, getBrowserBodyText, getReactErrorOverlayContent } from 'next-test-utils'
export default (context, renderViaHTTP) => {
describe('Hot Module Reloading', () => {
......@@ -13,7 +13,7 @@ export default (context, renderViaHTTP) => {
browser = await webdriver(context.appPort, '/hello')
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 editedContent = originalContent.replace('Hello', 'COOL page')
......@@ -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
describe('TypeScript Features', () => {
beforeAll(async () => {
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
await Promise.all([renderViaHTTP(context.appPort, '/hello')])
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册