From 4ae3dbca77f0df284f79f1c20a68572a203c60fd Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Fri, 5 Aug 2022 12:00:47 -0500 Subject: [PATCH] Fix failing escheck test --- test/production/escheck-output/index.test.ts | 47 ++++++++++---------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/test/production/escheck-output/index.test.ts b/test/production/escheck-output/index.test.ts index a152ee0e64abb..85ee83d2cfe17 100644 --- a/test/production/escheck-output/index.test.ts +++ b/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! 🎉' ) })