mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Remove the default HMR error overlay (#4020)
This is supplied by webpack-hot-middleware. I also added a test case to prevent this from popping up again.
This commit is contained in:
parent
17db533be5
commit
1844a09023
|
@ -1,5 +1,5 @@
|
|||
import 'event-source-polyfill'
|
||||
import webpackHotMiddlewareClient from 'webpack-hot-middleware/client?autoConnect=false'
|
||||
import webpackHotMiddlewareClient from 'webpack-hot-middleware/client?autoConnect=false&overlay=false&reload=true'
|
||||
import Router from '../lib/router'
|
||||
|
||||
const {
|
||||
|
@ -10,8 +10,6 @@ const {
|
|||
|
||||
export default () => {
|
||||
webpackHotMiddlewareClient.setOptionsAndConnect({
|
||||
overlay: 'false',
|
||||
reload: 'true',
|
||||
path: `${assetPrefix}/_next/webpack-hmr`
|
||||
})
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* global describe, it, expect */
|
||||
import webdriver from 'next-webdriver'
|
||||
import { join } from 'path'
|
||||
import { check, File } from 'next-test-utils'
|
||||
import { check, File, waitFor } from 'next-test-utils'
|
||||
|
||||
export default (context, render) => {
|
||||
describe('Error Recovery', () => {
|
||||
|
@ -29,6 +29,30 @@ export default (context, render) => {
|
|||
browser.close()
|
||||
})
|
||||
|
||||
it('should not show the default HMR error overlay', async() => {
|
||||
const browser = await webdriver(context.appPort, '/hmr/about')
|
||||
const text = await browser
|
||||
.elementByCss('p').text()
|
||||
expect(text).toBe('This is the about page.')
|
||||
|
||||
const aboutPage = new File(join(__dirname, '../', 'pages', 'hmr', 'about.js'))
|
||||
aboutPage.replace('</div>', 'div')
|
||||
|
||||
await check(
|
||||
() => browser.elementByCss('body').text(),
|
||||
/Unterminated JSX contents/
|
||||
)
|
||||
|
||||
await waitFor(2000)
|
||||
|
||||
// Check for the error overlay
|
||||
const bodyHtml = await browser.elementByCss('body').getAttribute('innerHTML')
|
||||
expect(bodyHtml.includes('webpack-hot-middleware-clientOverlay')).toBeFalsy()
|
||||
|
||||
aboutPage.restore()
|
||||
browser.close()
|
||||
})
|
||||
|
||||
it('should show the error on all pages', async () => {
|
||||
const aboutPage = new File(join(__dirname, '../', 'pages', 'hmr', 'about.js'))
|
||||
aboutPage.replace('</div>', 'div')
|
||||
|
|
Loading…
Reference in a new issue