Unverified Commit 48ab605b authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

tests: reenable escheck-output (#90423)

Various bugs I reported to https://github.com/yowainwright/es-check/ are fixed now, and there aren't any false negatives anymore.
parent e160f03f
'use client'
export default function Page() {
return <button>Client</button>
}
export default function RootLayout({ children }) {
return (
<html>
<head />
<body>{children}</body>
</html>
)
}
import { createNext } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
import { NextInstance } from 'e2e-utils' import { execSync } from 'child_process'
// Currently broken: https://github.com/yowainwright/es-check/issues/321 const dependencies = {
describe.skip('ES Check .next output', () => { 'es-check': '9.6.1',
let next: NextInstance browserslist: '4.28.1',
afterEach(() => next.destroy()) }
it('should downlevel JS according to manual browserslist with es2020', async () => { describe('escheck-output', () => {
describe('es2020', () => {
let browserslist = [ let browserslist = [
'chrome 64', 'chrome 64',
'edge 79', 'edge 79',
...@@ -14,38 +15,63 @@ describe.skip('ES Check .next output', () => { ...@@ -14,38 +15,63 @@ describe.skip('ES Check .next output', () => {
'opera 51', 'opera 51',
'safari 12', 'safari 12',
] ]
next = await createNext({ const { next } = nextTestSetup({
files: __dirname, files: __dirname,
dependencies: { 'es-check': '9.4.3' }, dependencies,
packageJson: { packageJson: {
browserslist: browserslist, browserslist,
scripts: {
build: 'next build && es-check es2020 ".next/static/**/*.js"',
},
}, },
installCommand: 'pnpm i',
buildCommand: 'pnpm build',
}) })
expect(next.cliOutput).toContain(
'info: ES-Check: there were no ES version matching errors! 🎉' it('should downlevel JS', () => {
) let esCheckOutput = execSync(
'node_modules/.bin/es-check es2020 ".next/static/**/*.js" --noCache',
{ cwd: next.testDir, encoding: 'utf8' }
)
expect(esCheckOutput).toContain('info: ✓ ES-Check passed!')
})
}) })
it('should downlevel JS according to default browserslist', async () => { describe('default browserslist', () => {
let browserslist = ['chrome 111', 'edge 111', 'firefox 111', 'safari 16.4'] let browserslist = ['chrome 111', 'edge 111', 'firefox 111', 'safari 16.4']
next = await createNext({
const { next } = nextTestSetup({
files: __dirname, files: __dirname,
dependencies: { 'es-check': '9.4.3' }, dependencies,
packageJson: { packageJson: {
scripts: { browserslist,
build: `next build && es-check checkBrowser ".next/static/**/*.js" --browserslistQuery="${browserslist.join(', ')}"`,
},
}, },
installCommand: 'pnpm i',
buildCommand: 'pnpm build',
}) })
expect(next.cliOutput).toContain(
'info: ES-Check: there were no ES version matching errors! 🎉' it('should downlevel JS', () => {
) let esCheckOutput = execSync(
`node_modules/.bin/es-check checkBrowser ".next/static/**/*.js" --browserslistQuery="${browserslist.join(', ')}" --noCache`,
{ cwd: next.testDir, encoding: 'utf8' }
)
expect(esCheckOutput).toContain('info: ✓ ES-Check passed!')
})
})
describe('nomodule browsers', () => {
let browserslist = ['chrome 60']
const { next } = nextTestSetup({
files: __dirname,
dependencies,
packageJson: {
browserslist,
},
})
it('should downlevel JS', () => {
let esCheckOutput = execSync(
`node_modules/.bin/es-check checkBrowser ".next/static/**/*.js" --browserslistQuery="${browserslist.join(', ')}" --noCache`,
{ cwd: next.testDir, encoding: 'utf8' }
)
expect(esCheckOutput).toContain('info: ✓ ES-Check passed!')
})
}) })
}) })
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