Skip to content

Commit

Permalink
Fix failing escheck test (#39365)
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Aug 5, 2022
1 parent 5f483b9 commit 442378d
Showing 1 changed file with 24 additions and 23 deletions.
47 changes: 24 additions & 23 deletions test/production/escheck-output/index.test.ts
@@ -1,43 +1,44 @@
import { createNext } from 'e2e-utils'
import execa from 'execa'
import { NextConfig } from 'packages/next'
import { NextInstance } from 'test/lib/next-modes/base'

describe('ES Check default output', () => {
let next: NextInstance

afterEach(() => next.destroy())

it('should pass for ES5', async () => {
beforeAll(async () => {
next = await createNext({
files: { 'pages/index.js': 'export default function Page() {}' },
files: {
'pages/index.js': 'export default function Page() { return "hello" }',
},
dependencies: { 'es-check': '7.0.0' },
packageJson: {
scripts: {
build: 'next build && es-check es5 .next/static/**/*.js',
},
},
buildCommand: 'yarn build',
})
})
afterAll(() => next.destroy())

const res = await execa(
'pnpm',
['es-check', 'es5', '.next/static/**/*.js'],
{ cwd: next.testDir }
)

expect(res.stdout).toBe(
it('should pass for ES5', async () => {
expect(next.cliOutput).toContain(
'info: ES-Check: there were no ES version matching errors! 🎉'
)
})

it('should pass for ES5 with SWC minify', async () => {
next = await createNext({
files: { 'pages/index.js': 'export default function Page() {}' },
dependencies: { 'es-check': '7.0.0' },
nextConfig: { swcMinify: true },
})

const res = await execa(
'pnpm',
['es-check', 'es5', '.next/static/**/*.js'],
{ cwd: next.testDir }
await next.stop()
await next.deleteFile('.next')
await next.patchFile(
'next.config.js',
`
module.exports = ${JSON.stringify({ swcMinify: true } as NextConfig)}
`
)
await next.start()

expect(res.stdout).toBe(
expect(next.cliOutput).toContain(
'info: ES-Check: there were no ES version matching errors! 🎉'
)
})
Expand Down

0 comments on commit 442378d

Please sign in to comment.