|
|
import { nextTestSetup } from 'e2e-utils' |
|
|
import { check } from 'next-test-utils' |
|
|
|
|
|
describe('custom-app-hmr', () => { |
|
|
const { next } = nextTestSetup({ |
|
|
files: __dirname, |
|
|
}) |
|
|
it('should not do full reload when simply editing _app.js', async () => { |
|
|
const customAppFilePath = 'pages/_app.js' |
|
|
const browser = await next.browser('/') |
|
|
await browser.eval('window.hmrConstantValue = "should-not-change"') |
|
|
|
|
|
const customAppContent = await next.readFile(customAppFilePath) |
|
|
const newCustomAppContent = customAppContent.replace( |
|
|
'hmr text origin', |
|
|
'hmr text changed' |
|
|
) |
|
|
await next.patchFile(customAppFilePath, newCustomAppContent) |
|
|
|
|
|
await check(async () => { |
|
|
const pText = await browser.elementByCss('h1').text() |
|
|
expect(pText).toBe('hmr text changed') |
|
|
|
|
|
|
|
|
const hmrConstantValue = await browser.eval('window.hmrConstantValue') |
|
|
expect(hmrConstantValue).toBe('should-not-change') |
|
|
|
|
|
return 'success' |
|
|
}, 'success') |
|
|
|
|
|
await next.patchFile(customAppFilePath, customAppContent) |
|
|
await check(async () => { |
|
|
const pText = await browser.elementByCss('h1').text() |
|
|
expect(pText).toBe('hmr text origin') |
|
|
|
|
|
|
|
|
const hmrConstantValue = await browser.eval('window.hmrConstantValue') |
|
|
expect(hmrConstantValue).toBe('should-not-change') |
|
|
|
|
|
return 'success' |
|
|
}, 'success') |
|
|
}) |
|
|
}) |
|
|
|