Files
next.js/test/e2e/browserslist/default-target.test.ts
4588a73542 Convert tests using createNext -> nextTestSetup (#93767)
## What?

Converts existing `createNext()` usage into `nextTestSetup()`. 

`createNext()` was the setup step we had before `nextTestSetup()` was
added.

This PR focused on the simple conversion cases. There will be a
follow-up to complete the last few.

---------

Co-authored-by: Cursor <[email protected]>
2026-05-12 13:16:31 +02:00

41 lines
1.1 KiB
TypeScript

import { FileRef, nextTestSetup } from 'e2e-utils'
import { renderViaHTTP, fetchViaHTTP } from 'next-test-utils'
import path from 'path'
import cheerio from 'cheerio'
const appDir = path.join(__dirname, 'app')
// TODO: This test needs to check multiple files and syntax features.
describe.skip('default browserslist target', () => {
const { next } = nextTestSetup({
files: {
pages: new FileRef(path.join(appDir, 'pages')),
},
})
it('should apply default browserslist target', async () => {
const html = await renderViaHTTP(next.url, '/')
const $ = cheerio.load(html)
expect(
(
await Promise.all(
$('script')
.toArray()
.map(async (el) => {
const src = $(el).attr('src')
const res = await fetchViaHTTP(next.url, src)
const code = await res.text()
// Default compiles for ES Modules output
if (code.includes('async ()=>')) {
return src
}
return false
})
)
)
// Filter out false values
.filter((item) => item)
).not.toBeEmpty()
})
})