Skip to content

Commit

Permalink
Ensure HMR was applied
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Aug 20, 2024
1 parent fa5eae8 commit 6f3b8f7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion test/development/app-dir/dev-fetch-hmr/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export default async function Page() {
// touch to trigger HMR
const secret = (await fetch('http://fake.url/secret').then((res) =>
res.text()
)) as any
Expand All @@ -9,6 +8,7 @@ export default async function Page() {

return (
<>
<div id="update">touch to trigger HMR</div>
<div id="secret">{secret}</div>
<div id="magic-number">{magicNumber}</div>
</>
Expand Down
10 changes: 8 additions & 2 deletions test/development/app-dir/dev-fetch-hmr/dev-fetch-hmr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ describe('dev-fetch-hmr', () => {
const html2 = await next.render('/')
expect(html2).toContain('monkey patching is fun')
const magicNumber2 = cheerio.load(html2)('#magic-number').text()
expect(magicNumber).toBe(magicNumber2)
// Module was not re-evaluated
expect(magicNumber2).toBe(magicNumber)
const update = cheerio.load(html2)('#update').text()
expect(update).toBe('touch to trigger HMR')

// trigger HMR
await next.patchFile('app/page.tsx', (content) =>
Expand All @@ -26,9 +29,12 @@ describe('dev-fetch-hmr', () => {

await retry(async () => {
const html3 = await next.render('/')
const update2 = cheerio.load(html3)('#update').text()
expect(update2).toBe('touch to trigger HMR 2')
const magicNumber3 = cheerio.load(html3)('#magic-number').text()
expect(html3).toContain('monkey patching is fun')
expect(magicNumber).not.toEqual(magicNumber3)
// Module was re-evaluated
expect(magicNumber3).not.toEqual(magicNumber)
})
})
})

0 comments on commit 6f3b8f7

Please sign in to comment.