Skip to content

Commit a64f6b0

Browse files
authored
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`)
1 parent ed16054 commit a64f6b0

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

test/development/basic/hmr/run-error-recovery-hmr-test.util.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
getRedboxHeader,
77
getRedboxDescription,
88
getRedboxSource,
9-
renderViaHTTP,
109
retry,
1110
waitFor,
1211
trimEndMultiline,
@@ -245,7 +244,7 @@ export function runErrorRecoveryHmrTest(nextConfig: {
245244
const aboutContent = await next.readFile(aboutPage)
246245
const browser = await next.browser(basePath + '/hmr/contact')
247246
try {
248-
await renderViaHTTP(next.url, basePath + '/hmr/about2')
247+
await next.render(basePath + '/hmr/about2')
249248

250249
await next.patchFile(aboutPage, aboutContent.replace('</div>', 'div'))
251250

test/development/basic/hmr/run-hot-module-reload-hmr-test.util.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
import { join } from 'path'
2-
import cheerio from 'cheerio'
3-
import {
4-
getBrowserBodyText,
5-
renderViaHTTP,
6-
retry,
7-
waitFor,
8-
} from 'next-test-utils'
2+
import { getBrowserBodyText, retry, waitFor } from 'next-test-utils'
93
import { nextTestSetup } from 'e2e-utils'
104

115
export function runHotModuleReloadHmrTest(nextConfig: {
@@ -197,13 +191,14 @@ export function runHotModuleReloadHmrTest(nextConfig: {
197191

198192
expect(initialFontSize).toBe('100px')
199193

200-
const initialHtml = await renderViaHTTP(
201-
next.url,
194+
const initialHtml = await next.render(
202195
basePath + '/hmr/style-dynamic-component'
203196
)
204197
expect(initialHtml.includes('100px')).toBeTruthy()
205198

206-
const $initialHtml = cheerio.load(initialHtml)
199+
const $initialHtml = await next.render$(
200+
basePath + '/hmr/style-dynamic-component'
201+
)
207202
const initialServerClassName =
208203
$initialHtml('#dynamic-component').attr('class')
209204

@@ -229,12 +224,13 @@ export function runHotModuleReloadHmrTest(nextConfig: {
229224
expect(browserHtml.includes('font-size:200px')).toBe(true)
230225
expect(browserHtml.includes('font-size:100px')).toBe(false)
231226

232-
const editedHtml = await renderViaHTTP(
233-
next.url,
227+
const editedHtml = await next.render(
234228
basePath + '/hmr/style-dynamic-component'
235229
)
236230
expect(editedHtml.includes('200px')).toBeTruthy()
237-
const $editedHtml = cheerio.load(editedHtml)
231+
const $editedHtml = await next.render$(
232+
basePath + '/hmr/style-dynamic-component'
233+
)
238234
const editedServerClassName =
239235
$editedHtml('#dynamic-component').attr('class')
240236

0 commit comments

Comments
 (0)