Unverified Commit a64f6b07 authored by Jiwon Choi's avatar Jiwon Choi Committed by GitHub

test: replace duplicate test utils to next instance (#73624)

This PR replaces:
- `renderViaHTTP -> next.render`
- `cheerio.load -> next.render$`
- ~~`process.env.TURBOPACK` -> `isTurbopack`~~ (left as
`process.env.IS_TURBOPACK_TEST`)
parent ed160544
...@@ -6,7 +6,6 @@ import { ...@@ -6,7 +6,6 @@ import {
getRedboxHeader, getRedboxHeader,
getRedboxDescription, getRedboxDescription,
getRedboxSource, getRedboxSource,
renderViaHTTP,
retry, retry,
waitFor, waitFor,
trimEndMultiline, trimEndMultiline,
...@@ -245,7 +244,7 @@ export function runErrorRecoveryHmrTest(nextConfig: { ...@@ -245,7 +244,7 @@ export function runErrorRecoveryHmrTest(nextConfig: {
const aboutContent = await next.readFile(aboutPage) const aboutContent = await next.readFile(aboutPage)
const browser = await next.browser(basePath + '/hmr/contact') const browser = await next.browser(basePath + '/hmr/contact')
try { try {
await renderViaHTTP(next.url, basePath + '/hmr/about2') await next.render(basePath + '/hmr/about2')
await next.patchFile(aboutPage, aboutContent.replace('</div>', 'div')) await next.patchFile(aboutPage, aboutContent.replace('</div>', 'div'))
......
import { join } from 'path' import { join } from 'path'
import cheerio from 'cheerio' import { getBrowserBodyText, retry, waitFor } from 'next-test-utils'
import {
getBrowserBodyText,
renderViaHTTP,
retry,
waitFor,
} from 'next-test-utils'
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
export function runHotModuleReloadHmrTest(nextConfig: { export function runHotModuleReloadHmrTest(nextConfig: {
...@@ -197,13 +191,14 @@ export function runHotModuleReloadHmrTest(nextConfig: { ...@@ -197,13 +191,14 @@ export function runHotModuleReloadHmrTest(nextConfig: {
expect(initialFontSize).toBe('100px') expect(initialFontSize).toBe('100px')
const initialHtml = await renderViaHTTP( const initialHtml = await next.render(
next.url,
basePath + '/hmr/style-dynamic-component' basePath + '/hmr/style-dynamic-component'
) )
expect(initialHtml.includes('100px')).toBeTruthy() expect(initialHtml.includes('100px')).toBeTruthy()
const $initialHtml = cheerio.load(initialHtml) const $initialHtml = await next.render$(
basePath + '/hmr/style-dynamic-component'
)
const initialServerClassName = const initialServerClassName =
$initialHtml('#dynamic-component').attr('class') $initialHtml('#dynamic-component').attr('class')
...@@ -229,12 +224,13 @@ export function runHotModuleReloadHmrTest(nextConfig: { ...@@ -229,12 +224,13 @@ export function runHotModuleReloadHmrTest(nextConfig: {
expect(browserHtml.includes('font-size:200px')).toBe(true) expect(browserHtml.includes('font-size:200px')).toBe(true)
expect(browserHtml.includes('font-size:100px')).toBe(false) expect(browserHtml.includes('font-size:100px')).toBe(false)
const editedHtml = await renderViaHTTP( const editedHtml = await next.render(
next.url,
basePath + '/hmr/style-dynamic-component' basePath + '/hmr/style-dynamic-component'
) )
expect(editedHtml.includes('200px')).toBeTruthy() expect(editedHtml.includes('200px')).toBeTruthy()
const $editedHtml = cheerio.load(editedHtml) const $editedHtml = await next.render$(
basePath + '/hmr/style-dynamic-component'
)
const editedServerClassName = const editedServerClassName =
$editedHtml('#dynamic-component').attr('class') $editedHtml('#dynamic-component').attr('class')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment