diff --git a/test/development/basic/hmr/__tests__/error-recovery/error-recovery-no-base-path-no-asset-prefix.test.ts b/test/development/basic/hmr/__tests__/error-recovery/error-recovery-no-base-path-no-asset-prefix.test.ts index bfd16c18f78cf..ba277fb35c3f9 100644 --- a/test/development/basic/hmr/__tests__/error-recovery/error-recovery-no-base-path-no-asset-prefix.test.ts +++ b/test/development/basic/hmr/__tests__/error-recovery/error-recovery-no-base-path-no-asset-prefix.test.ts @@ -6,7 +6,6 @@ import { getRedboxHeader, getRedboxDescription, getRedboxSource, - renderViaHTTP, retry, waitFor, } from 'next-test-utils' @@ -16,7 +15,7 @@ import { outdent } from 'outdent' const nextConfig = { basePath: '', assetPrefix: '' } describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () => { - const { next } = nextTestSetup({ + const { next, isTurbopack } = nextTestSetup({ files: join(__dirname, '../../fixtures'), nextConfig, patchFileDelay: 500, @@ -92,7 +91,7 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = throw err } }) - ;(process.env.TURBOPACK ? it.skip : it)( + ;(isTurbopack ? it.skip : it)( // this test fails frequently with turbopack 'should not continously poll a custom error page', async () => { @@ -161,7 +160,7 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = await assertHasRedbox(browser) const source = next.normalizeTestDirContent(await getRedboxSource(browser)) - if (basePath === '' && !process.env.TURBOPACK) { + if (basePath === '' && !isTurbopack) { expect(source).toMatchInlineSnapshot(` "./pages/hmr/about2.js Error: x Unexpected token. Did you mean \`{'}'}\` or \`}\`? @@ -185,7 +184,7 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = Import trace for requested module: ./pages/hmr/about2.js" `) - } else if (basePath === '' && process.env.TURBOPACK) { + } else if (basePath === '' && isTurbopack) { expect(source).toMatchInlineSnapshot(` "./pages/hmr/about2.js:7:1 Parsing ecmascript source code failed @@ -197,7 +196,7 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = Unexpected token. Did you mean \`{'}'}\` or \`}\`?" `) - } else if (basePath === '/docs' && !process.env.TURBOPACK) { + } else if (basePath === '/docs' && !isTurbopack) { expect(source).toMatchInlineSnapshot(` "./pages/hmr/about2.js Error: x Unexpected token. Did you mean \`{'}'}\` or \`}\`? @@ -221,7 +220,7 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = Import trace for requested module: ./pages/hmr/about2.js" `) - } else if (basePath === '/docs' && process.env.TURBOPACK) { + } else if (basePath === '/docs' && isTurbopack) { expect(source).toMatchInlineSnapshot(` "./pages/hmr/about2.js:7:1 Parsing ecmascript source code failed @@ -244,14 +243,14 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = }) }) - if (!process.env.TURBOPACK) { + if (!isTurbopack) { // Turbopack doesn't have this restriction it('should show the error on all pages', async () => { const aboutPage = join('pages', 'hmr', 'about2.js') const aboutContent = await next.readFile(aboutPage) const browser = await next.browser(basePath + '/hmr/contact') try { - await renderViaHTTP(next.url, basePath + '/hmr/about2') + await next.render(basePath + '/hmr/about2') await next.patchFile(aboutPage, aboutContent.replace('', 'div')) @@ -513,7 +512,7 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = await assertHasRedbox(browser) expect(await getRedboxHeader(browser)).toMatch('Failed to compile') - if (process.env.TURBOPACK) { + if (isTurbopack) { expect(await getRedboxSource(browser)).toMatchInlineSnapshot(` "./components/parse-error.xyz Unknown module type @@ -583,7 +582,7 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = let redboxSource = await getRedboxSource(browser) redboxSource = redboxSource.replace(`${next.testDir}`, '.') - if (process.env.TURBOPACK) { + if (isTurbopack) { expect(next.normalizeTestDirContent(redboxSource)) .toMatchInlineSnapshot(` "./components/parse-error.js:3:1 @@ -716,7 +715,7 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = } }) - if (!process.env.TURBOPACK) { + if (!isTurbopack) { it('should have client HMR events in trace file', async () => { const traceData = await next.readFile('.next/trace') expect(traceData).toContain('client-hmr-latency') diff --git a/test/development/basic/hmr/__tests__/error-recovery/error-recovery-no-base-path-yes-asset-prefix.test.ts b/test/development/basic/hmr/__tests__/error-recovery/error-recovery-no-base-path-yes-asset-prefix.test.ts index 254ead9d5809f..a3cbe500af237 100644 --- a/test/development/basic/hmr/__tests__/error-recovery/error-recovery-no-base-path-yes-asset-prefix.test.ts +++ b/test/development/basic/hmr/__tests__/error-recovery/error-recovery-no-base-path-yes-asset-prefix.test.ts @@ -6,7 +6,6 @@ import { getRedboxHeader, getRedboxDescription, getRedboxSource, - renderViaHTTP, retry, waitFor, } from 'next-test-utils' @@ -16,7 +15,7 @@ import { outdent } from 'outdent' const nextConfig = { basePath: '', assetPrefix: '/asset-prefix' } describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () => { - const { next } = nextTestSetup({ + const { next, isTurbopack } = nextTestSetup({ files: join(__dirname, '../../fixtures'), nextConfig, patchFileDelay: 500, @@ -92,7 +91,7 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = throw err } }) - ;(process.env.TURBOPACK ? it.skip : it)( + ;(isTurbopack ? it.skip : it)( // this test fails frequently with turbopack 'should not continously poll a custom error page', async () => { @@ -161,7 +160,7 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = await assertHasRedbox(browser) const source = next.normalizeTestDirContent(await getRedboxSource(browser)) - if (basePath === '' && !process.env.TURBOPACK) { + if (basePath === '' && !isTurbopack) { expect(source).toMatchInlineSnapshot(` "./pages/hmr/about2.js Error: x Unexpected token. Did you mean \`{'}'}\` or \`}\`? @@ -185,7 +184,7 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = Import trace for requested module: ./pages/hmr/about2.js" `) - } else if (basePath === '' && process.env.TURBOPACK) { + } else if (basePath === '' && isTurbopack) { expect(source).toMatchInlineSnapshot(` "./pages/hmr/about2.js:7:1 Parsing ecmascript source code failed @@ -197,7 +196,7 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = Unexpected token. Did you mean \`{'}'}\` or \`}\`?" `) - } else if (basePath === '/docs' && !process.env.TURBOPACK) { + } else if (basePath === '/docs' && !isTurbopack) { expect(source).toMatchInlineSnapshot(` "./pages/hmr/about2.js Error: x Unexpected token. Did you mean \`{'}'}\` or \`}\`? @@ -221,7 +220,7 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = Import trace for requested module: ./pages/hmr/about2.js" `) - } else if (basePath === '/docs' && process.env.TURBOPACK) { + } else if (basePath === '/docs' && isTurbopack) { expect(source).toMatchInlineSnapshot(` "./pages/hmr/about2.js:7:1 Parsing ecmascript source code failed @@ -244,14 +243,14 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = }) }) - if (!process.env.TURBOPACK) { + if (!isTurbopack) { // Turbopack doesn't have this restriction it('should show the error on all pages', async () => { const aboutPage = join('pages', 'hmr', 'about2.js') const aboutContent = await next.readFile(aboutPage) const browser = await next.browser(basePath + '/hmr/contact') try { - await renderViaHTTP(next.url, basePath + '/hmr/about2') + await next.render(basePath + '/hmr/about2') await next.patchFile(aboutPage, aboutContent.replace('', 'div')) @@ -513,7 +512,7 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = await assertHasRedbox(browser) expect(await getRedboxHeader(browser)).toMatch('Failed to compile') - if (process.env.TURBOPACK) { + if (isTurbopack) { expect(await getRedboxSource(browser)).toMatchInlineSnapshot(` "./components/parse-error.xyz Unknown module type @@ -583,7 +582,7 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = let redboxSource = await getRedboxSource(browser) redboxSource = redboxSource.replace(`${next.testDir}`, '.') - if (process.env.TURBOPACK) { + if (isTurbopack) { expect(next.normalizeTestDirContent(redboxSource)) .toMatchInlineSnapshot(` "./components/parse-error.js:3:1 @@ -716,7 +715,7 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = } }) - if (!process.env.TURBOPACK) { + if (!isTurbopack) { it('should have client HMR events in trace file', async () => { const traceData = await next.readFile('.next/trace') expect(traceData).toContain('client-hmr-latency') diff --git a/test/development/basic/hmr/__tests__/error-recovery/error-recovery-yes-base-path-no-asset-prefix.test.ts b/test/development/basic/hmr/__tests__/error-recovery/error-recovery-yes-base-path-no-asset-prefix.test.ts index 5ea3393f30516..91a74e737fcd1 100644 --- a/test/development/basic/hmr/__tests__/error-recovery/error-recovery-yes-base-path-no-asset-prefix.test.ts +++ b/test/development/basic/hmr/__tests__/error-recovery/error-recovery-yes-base-path-no-asset-prefix.test.ts @@ -6,7 +6,6 @@ import { getRedboxHeader, getRedboxDescription, getRedboxSource, - renderViaHTTP, retry, waitFor, } from 'next-test-utils' @@ -16,7 +15,7 @@ import { outdent } from 'outdent' const nextConfig = { basePath: '/docs', assetPrefix: '' } describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () => { - const { next } = nextTestSetup({ + const { next, isTurbopack } = nextTestSetup({ files: join(__dirname, '../../fixtures'), nextConfig, patchFileDelay: 500, @@ -92,7 +91,7 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = throw err } }) - ;(process.env.TURBOPACK ? it.skip : it)( + ;(isTurbopack ? it.skip : it)( // this test fails frequently with turbopack 'should not continously poll a custom error page', async () => { @@ -161,7 +160,7 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = await assertHasRedbox(browser) const source = next.normalizeTestDirContent(await getRedboxSource(browser)) - if (basePath === '' && !process.env.TURBOPACK) { + if (basePath === '' && !isTurbopack) { expect(source).toMatchInlineSnapshot(` "./pages/hmr/about2.js Error: x Unexpected token. Did you mean \`{'}'}\` or \`}\`? @@ -185,7 +184,7 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = Import trace for requested module: ./pages/hmr/about2.js" `) - } else if (basePath === '' && process.env.TURBOPACK) { + } else if (basePath === '' && isTurbopack) { expect(source).toMatchInlineSnapshot(` "./pages/hmr/about2.js:7:1 Parsing ecmascript source code failed @@ -197,7 +196,7 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = Unexpected token. Did you mean \`{'}'}\` or \`}\`?" `) - } else if (basePath === '/docs' && !process.env.TURBOPACK) { + } else if (basePath === '/docs' && !isTurbopack) { expect(source).toMatchInlineSnapshot(` "./pages/hmr/about2.js Error: x Unexpected token. Did you mean \`{'}'}\` or \`}\`? @@ -221,7 +220,7 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = Import trace for requested module: ./pages/hmr/about2.js" `) - } else if (basePath === '/docs' && process.env.TURBOPACK) { + } else if (basePath === '/docs' && isTurbopack) { expect(source).toMatchInlineSnapshot(` "./pages/hmr/about2.js:7:1 Parsing ecmascript source code failed @@ -244,14 +243,14 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = }) }) - if (!process.env.TURBOPACK) { + if (!isTurbopack) { // Turbopack doesn't have this restriction it('should show the error on all pages', async () => { const aboutPage = join('pages', 'hmr', 'about2.js') const aboutContent = await next.readFile(aboutPage) const browser = await next.browser(basePath + '/hmr/contact') try { - await renderViaHTTP(next.url, basePath + '/hmr/about2') + await next.render(basePath + '/hmr/about2') await next.patchFile(aboutPage, aboutContent.replace('', 'div')) @@ -513,7 +512,7 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = await assertHasRedbox(browser) expect(await getRedboxHeader(browser)).toMatch('Failed to compile') - if (process.env.TURBOPACK) { + if (isTurbopack) { expect(await getRedboxSource(browser)).toMatchInlineSnapshot(` "./components/parse-error.xyz Unknown module type @@ -583,7 +582,7 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = let redboxSource = await getRedboxSource(browser) redboxSource = redboxSource.replace(`${next.testDir}`, '.') - if (process.env.TURBOPACK) { + if (isTurbopack) { expect(next.normalizeTestDirContent(redboxSource)) .toMatchInlineSnapshot(` "./components/parse-error.js:3:1 @@ -716,7 +715,7 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = } }) - if (!process.env.TURBOPACK) { + if (!isTurbopack) { it('should have client HMR events in trace file', async () => { const traceData = await next.readFile('.next/trace') expect(traceData).toContain('client-hmr-latency') diff --git a/test/development/basic/hmr/__tests__/error-recovery/error-recovery-yes-base-path-yes-asset-prefix.test.ts b/test/development/basic/hmr/__tests__/error-recovery/error-recovery-yes-base-path-yes-asset-prefix.test.ts index 3be32cc05c140..b6b802791c82e 100644 --- a/test/development/basic/hmr/__tests__/error-recovery/error-recovery-yes-base-path-yes-asset-prefix.test.ts +++ b/test/development/basic/hmr/__tests__/error-recovery/error-recovery-yes-base-path-yes-asset-prefix.test.ts @@ -6,7 +6,6 @@ import { getRedboxHeader, getRedboxDescription, getRedboxSource, - renderViaHTTP, retry, waitFor, } from 'next-test-utils' @@ -16,7 +15,7 @@ import { outdent } from 'outdent' const nextConfig = { basePath: '/docs', assetPrefix: '/asset-prefix' } describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () => { - const { next } = nextTestSetup({ + const { next, isTurbopack } = nextTestSetup({ files: join(__dirname, '../../fixtures'), nextConfig, patchFileDelay: 500, @@ -92,7 +91,7 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = throw err } }) - ;(process.env.TURBOPACK ? it.skip : it)( + ;(isTurbopack ? it.skip : it)( // this test fails frequently with turbopack 'should not continously poll a custom error page', async () => { @@ -161,7 +160,7 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = await assertHasRedbox(browser) const source = next.normalizeTestDirContent(await getRedboxSource(browser)) - if (basePath === '' && !process.env.TURBOPACK) { + if (basePath === '' && !isTurbopack) { expect(source).toMatchInlineSnapshot(` "./pages/hmr/about2.js Error: x Unexpected token. Did you mean \`{'}'}\` or \`}\`? @@ -185,7 +184,7 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = Import trace for requested module: ./pages/hmr/about2.js" `) - } else if (basePath === '' && process.env.TURBOPACK) { + } else if (basePath === '' && isTurbopack) { expect(source).toMatchInlineSnapshot(` "./pages/hmr/about2.js:7:1 Parsing ecmascript source code failed @@ -197,7 +196,7 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = Unexpected token. Did you mean \`{'}'}\` or \`}\`?" `) - } else if (basePath === '/docs' && !process.env.TURBOPACK) { + } else if (basePath === '/docs' && !isTurbopack) { expect(source).toMatchInlineSnapshot(` "./pages/hmr/about2.js Error: x Unexpected token. Did you mean \`{'}'}\` or \`}\`? @@ -221,7 +220,7 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = Import trace for requested module: ./pages/hmr/about2.js" `) - } else if (basePath === '/docs' && process.env.TURBOPACK) { + } else if (basePath === '/docs' && isTurbopack) { expect(source).toMatchInlineSnapshot(` "./pages/hmr/about2.js:7:1 Parsing ecmascript source code failed @@ -244,14 +243,14 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = }) }) - if (!process.env.TURBOPACK) { + if (!isTurbopack) { // Turbopack doesn't have this restriction it('should show the error on all pages', async () => { const aboutPage = join('pages', 'hmr', 'about2.js') const aboutContent = await next.readFile(aboutPage) const browser = await next.browser(basePath + '/hmr/contact') try { - await renderViaHTTP(next.url, basePath + '/hmr/about2') + await next.render(basePath + '/hmr/about2') await next.patchFile(aboutPage, aboutContent.replace('', 'div')) @@ -513,7 +512,7 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = await assertHasRedbox(browser) expect(await getRedboxHeader(browser)).toMatch('Failed to compile') - if (process.env.TURBOPACK) { + if (isTurbopack) { expect(await getRedboxSource(browser)).toMatchInlineSnapshot(` "./components/parse-error.xyz Unknown module type @@ -583,7 +582,7 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = let redboxSource = await getRedboxSource(browser) redboxSource = redboxSource.replace(`${next.testDir}`, '.') - if (process.env.TURBOPACK) { + if (isTurbopack) { expect(next.normalizeTestDirContent(redboxSource)) .toMatchInlineSnapshot(` "./components/parse-error.js:3:1 @@ -716,7 +715,7 @@ describe(`HMR - Error Recovery, nextConfig: ${JSON.stringify(nextConfig)}`, () = } }) - if (!process.env.TURBOPACK) { + if (!isTurbopack) { it('should have client HMR events in trace file', async () => { const traceData = await next.readFile('.next/trace') expect(traceData).toContain('client-hmr-latency') diff --git a/test/development/basic/hmr/__tests__/hot-module-reload/hot-module-reload-no-base-path-no-asset-prefix.test.ts b/test/development/basic/hmr/__tests__/hot-module-reload/hot-module-reload-no-base-path-no-asset-prefix.test.ts index cd15bd50e9898..bc8f1baba0837 100644 --- a/test/development/basic/hmr/__tests__/hot-module-reload/hot-module-reload-no-base-path-no-asset-prefix.test.ts +++ b/test/development/basic/hmr/__tests__/hot-module-reload/hot-module-reload-no-base-path-no-asset-prefix.test.ts @@ -1,11 +1,5 @@ import { join } from 'path' -import cheerio from 'cheerio' -import { - getBrowserBodyText, - renderViaHTTP, - retry, - waitFor, -} from 'next-test-utils' +import { getBrowserBodyText, retry, waitFor } from 'next-test-utils' import { nextTestSetup } from 'e2e-utils' const nextConfig = { basePath: '', assetPrefix: '' } @@ -196,13 +190,14 @@ describe(`HMR - Hot Module Reload, nextConfig: ${JSON.stringify(nextConfig)}`, ( expect(initialFontSize).toBe('100px') - const initialHtml = await renderViaHTTP( - next.url, + const initialHtml = await next.render( basePath + '/hmr/style-dynamic-component' ) expect(initialHtml.includes('100px')).toBeTruthy() - const $initialHtml = cheerio.load(initialHtml) + const $initialHtml = await next.render$( + basePath + '/hmr/style-dynamic-component' + ) const initialServerClassName = $initialHtml('#dynamic-component').attr('class') @@ -228,12 +223,13 @@ describe(`HMR - Hot Module Reload, nextConfig: ${JSON.stringify(nextConfig)}`, ( expect(browserHtml.includes('font-size:200px')).toBe(true) expect(browserHtml.includes('font-size:100px')).toBe(false) - const editedHtml = await renderViaHTTP( - next.url, + const editedHtml = await next.render( basePath + '/hmr/style-dynamic-component' ) expect(editedHtml.includes('200px')).toBeTruthy() - const $editedHtml = cheerio.load(editedHtml) + const $editedHtml = await next.render$( + basePath + '/hmr/style-dynamic-component' + ) const editedServerClassName = $editedHtml('#dynamic-component').attr('class') diff --git a/test/development/basic/hmr/__tests__/hot-module-reload/hot-module-reload-no-base-path-yes-asset-prefix.test.ts b/test/development/basic/hmr/__tests__/hot-module-reload/hot-module-reload-no-base-path-yes-asset-prefix.test.ts index ec3d396606713..4f56886578845 100644 --- a/test/development/basic/hmr/__tests__/hot-module-reload/hot-module-reload-no-base-path-yes-asset-prefix.test.ts +++ b/test/development/basic/hmr/__tests__/hot-module-reload/hot-module-reload-no-base-path-yes-asset-prefix.test.ts @@ -1,11 +1,5 @@ import { join } from 'path' -import cheerio from 'cheerio' -import { - getBrowserBodyText, - renderViaHTTP, - retry, - waitFor, -} from 'next-test-utils' +import { getBrowserBodyText, retry, waitFor } from 'next-test-utils' import { nextTestSetup } from 'e2e-utils' const nextConfig = { basePath: '', assetPrefix: '/asset-prefix' } @@ -196,13 +190,14 @@ describe(`HMR - Hot Module Reload, nextConfig: ${JSON.stringify(nextConfig)}`, ( expect(initialFontSize).toBe('100px') - const initialHtml = await renderViaHTTP( - next.url, + const initialHtml = await next.render( basePath + '/hmr/style-dynamic-component' ) expect(initialHtml.includes('100px')).toBeTruthy() - const $initialHtml = cheerio.load(initialHtml) + const $initialHtml = await next.render$( + basePath + '/hmr/style-dynamic-component' + ) const initialServerClassName = $initialHtml('#dynamic-component').attr('class') @@ -228,12 +223,13 @@ describe(`HMR - Hot Module Reload, nextConfig: ${JSON.stringify(nextConfig)}`, ( expect(browserHtml.includes('font-size:200px')).toBe(true) expect(browserHtml.includes('font-size:100px')).toBe(false) - const editedHtml = await renderViaHTTP( - next.url, + const editedHtml = await next.render( basePath + '/hmr/style-dynamic-component' ) expect(editedHtml.includes('200px')).toBeTruthy() - const $editedHtml = cheerio.load(editedHtml) + const $editedHtml = await next.render$( + basePath + '/hmr/style-dynamic-component' + ) const editedServerClassName = $editedHtml('#dynamic-component').attr('class') diff --git a/test/development/basic/hmr/__tests__/hot-module-reload/hot-module-reload-yes-base-path-no-asset-prefix.test.ts b/test/development/basic/hmr/__tests__/hot-module-reload/hot-module-reload-yes-base-path-no-asset-prefix.test.ts index f8c4c3890f787..569235447e5da 100644 --- a/test/development/basic/hmr/__tests__/hot-module-reload/hot-module-reload-yes-base-path-no-asset-prefix.test.ts +++ b/test/development/basic/hmr/__tests__/hot-module-reload/hot-module-reload-yes-base-path-no-asset-prefix.test.ts @@ -1,11 +1,5 @@ import { join } from 'path' -import cheerio from 'cheerio' -import { - getBrowserBodyText, - renderViaHTTP, - retry, - waitFor, -} from 'next-test-utils' +import { getBrowserBodyText, retry, waitFor } from 'next-test-utils' import { nextTestSetup } from 'e2e-utils' const nextConfig = { basePath: '/docs', assetPrefix: '' } @@ -196,13 +190,14 @@ describe(`HMR - Hot Module Reload, nextConfig: ${JSON.stringify(nextConfig)}`, ( expect(initialFontSize).toBe('100px') - const initialHtml = await renderViaHTTP( - next.url, + const initialHtml = await next.render( basePath + '/hmr/style-dynamic-component' ) expect(initialHtml.includes('100px')).toBeTruthy() - const $initialHtml = cheerio.load(initialHtml) + const $initialHtml = await next.render$( + basePath + '/hmr/style-dynamic-component' + ) const initialServerClassName = $initialHtml('#dynamic-component').attr('class') @@ -228,12 +223,13 @@ describe(`HMR - Hot Module Reload, nextConfig: ${JSON.stringify(nextConfig)}`, ( expect(browserHtml.includes('font-size:200px')).toBe(true) expect(browserHtml.includes('font-size:100px')).toBe(false) - const editedHtml = await renderViaHTTP( - next.url, + const editedHtml = await next.render( basePath + '/hmr/style-dynamic-component' ) expect(editedHtml.includes('200px')).toBeTruthy() - const $editedHtml = cheerio.load(editedHtml) + const $editedHtml = await next.render$( + basePath + '/hmr/style-dynamic-component' + ) const editedServerClassName = $editedHtml('#dynamic-component').attr('class') diff --git a/test/development/basic/hmr/__tests__/hot-module-reload/hot-module-reload-yes-base-path-yes-asset-prefix.test.ts b/test/development/basic/hmr/__tests__/hot-module-reload/hot-module-reload-yes-base-path-yes-asset-prefix.test.ts index f7d1783d78223..8fa2a7d02aeb5 100644 --- a/test/development/basic/hmr/__tests__/hot-module-reload/hot-module-reload-yes-base-path-yes-asset-prefix.test.ts +++ b/test/development/basic/hmr/__tests__/hot-module-reload/hot-module-reload-yes-base-path-yes-asset-prefix.test.ts @@ -1,11 +1,5 @@ import { join } from 'path' -import cheerio from 'cheerio' -import { - getBrowserBodyText, - renderViaHTTP, - retry, - waitFor, -} from 'next-test-utils' +import { getBrowserBodyText, retry, waitFor } from 'next-test-utils' import { nextTestSetup } from 'e2e-utils' const nextConfig = { basePath: '/docs', assetPrefix: '/asset-prefix' } @@ -196,13 +190,14 @@ describe(`HMR - Hot Module Reload, nextConfig: ${JSON.stringify(nextConfig)}`, ( expect(initialFontSize).toBe('100px') - const initialHtml = await renderViaHTTP( - next.url, + const initialHtml = await next.render( basePath + '/hmr/style-dynamic-component' ) expect(initialHtml.includes('100px')).toBeTruthy() - const $initialHtml = cheerio.load(initialHtml) + const $initialHtml = await next.render$( + basePath + '/hmr/style-dynamic-component' + ) const initialServerClassName = $initialHtml('#dynamic-component').attr('class') @@ -228,12 +223,13 @@ describe(`HMR - Hot Module Reload, nextConfig: ${JSON.stringify(nextConfig)}`, ( expect(browserHtml.includes('font-size:200px')).toBe(true) expect(browserHtml.includes('font-size:100px')).toBe(false) - const editedHtml = await renderViaHTTP( - next.url, + const editedHtml = await next.render( basePath + '/hmr/style-dynamic-component' ) expect(editedHtml.includes('200px')).toBeTruthy() - const $editedHtml = cheerio.load(editedHtml) + const $editedHtml = await next.render$( + basePath + '/hmr/style-dynamic-component' + ) const editedServerClassName = $editedHtml('#dynamic-component').attr('class')