rsnext/test/e2e/browserslist/legacybrowsers-true.test.ts
Steven cff9fc9d74
BREAKING CHANGE: Remove browsersListForSwc and change default to legacyBrowsers: false (#41529)
Remove `browsersListForSwc` since it is enabled by default now, and disable `legacyBrowsers` by default.

This PR also bumps the default browserslist to the following:

- Chrome 64+
- Edge 79+
- Firefox 67+
- Opera 51+
- Safari 12+

See related RFC:
- Closes #33227 

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-10-19 01:38:39 +00:00

47 lines
1.2 KiB
TypeScript

import { createNext, FileRef } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import { renderViaHTTP, fetchViaHTTP } from 'next-test-utils'
import path from 'path'
import cheerio from 'cheerio'
const appDir = path.join(__dirname, 'app')
describe('legacyBrowsers: true', () => {
let next: NextInstance
beforeAll(async () => {
next = await createNext({
files: {
pages: new FileRef(path.join(appDir, 'pages')),
},
nextConfig: {
experimental: {
legacyBrowsers: true,
},
},
dependencies: {},
})
})
afterAll(() => next.destroy())
it('should apply legacyBrowsers: true', async () => {
const html = await renderViaHTTP(next.url, '/')
const $ = cheerio.load(html)
let finished = false
await Promise.all(
$('script')
.toArray()
.map(async (el) => {
const src = $(el).attr('src')
if (!src) return
if (src.includes('/index')) {
const res = await fetchViaHTTP(next.url, src)
const code = await res.text()
expect(code).not.toMatch('()=>')
finished = true
}
})
)
expect(finished).toBe(true)
})
})