mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
## 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]>
41 lines
1.1 KiB
TypeScript
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()
|
|
})
|
|
})
|