From 6f3b8f77ed01fcf24363f90755f52056918ca310 Mon Sep 17 00:00:00 2001 From: eps1lon Date: Tue, 20 Aug 2024 16:42:51 +0200 Subject: [PATCH] Ensure HMR was applied --- test/development/app-dir/dev-fetch-hmr/app/page.tsx | 2 +- .../app-dir/dev-fetch-hmr/dev-fetch-hmr.test.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/test/development/app-dir/dev-fetch-hmr/app/page.tsx b/test/development/app-dir/dev-fetch-hmr/app/page.tsx index 49f122af9bfe0..ba0a22091d0f7 100644 --- a/test/development/app-dir/dev-fetch-hmr/app/page.tsx +++ b/test/development/app-dir/dev-fetch-hmr/app/page.tsx @@ -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 @@ -9,6 +8,7 @@ export default async function Page() { return ( <> +
touch to trigger HMR
{secret}
{magicNumber}
diff --git a/test/development/app-dir/dev-fetch-hmr/dev-fetch-hmr.test.ts b/test/development/app-dir/dev-fetch-hmr/dev-fetch-hmr.test.ts index 456e0f4bd5a7c..1457e456d676f 100644 --- a/test/development/app-dir/dev-fetch-hmr/dev-fetch-hmr.test.ts +++ b/test/development/app-dir/dev-fetch-hmr/dev-fetch-hmr.test.ts @@ -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) => @@ -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) }) }) })