Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix failing escheck test #39365

Merged
merged 1 commit into from Aug 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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