Skip to content

Commit

Permalink
Add a test case on error recovery in the module scope. (#3892)
Browse files Browse the repository at this point in the history
This is a test case related for #3888
  • Loading branch information
arunoda authored and timneutkens committed Feb 26, 2018
1 parent 9e39dd2 commit 0117e2b
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions test/integration/basic/test/hmr.js
Expand Up @@ -16,8 +16,8 @@ async function check (contentFn, regex) {

export default (context, render) => {
describe('Hot Module Reloading', () => {
describe('syntax error', () => {
it('should detect the error and recover', async () => {
describe('errors', () => {
it('should detect syntax errors and recover', async () => {
const browser = await webdriver(context.appPort, '/hmr/about')
const text = await browser
.elementByCss('p').text()
Expand Down Expand Up @@ -73,6 +73,36 @@ export default (context, render) => {

browser.close()
})

it('should detect runtime errors on the module scope', 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 aboutPagePath = join(__dirname, '../', 'pages', 'hmr', 'about.js')

const originalContent = readFileSync(aboutPagePath, 'utf8')
const erroredContent = originalContent.replace('export', 'aa=20;\nexport')

// change the content
writeFileSync(aboutPagePath, erroredContent, 'utf8')

await check(
() => browser.elementByCss('body').text(),
/aa is not defined/
)

// add the original content
writeFileSync(aboutPagePath, originalContent, 'utf8')

await check(
() => browser.elementByCss('body').text(),
/This is the about page/
)

browser.close()
})
})

describe('delete a page and add it back', () => {
Expand Down

0 comments on commit 0117e2b

Please sign in to comment.