From bf31b4ee8d3c59f87e539d34d20e1184e481c2fa Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Thu, 23 Jan 2020 12:28:23 -0500 Subject: [PATCH] Check CSS Test Output (#10237) * Check CSS Test Output * replace more * Fix tests * check code * Add code check * Check codes everywhere --- .../css-customization/test/index.test.js | 33 ++-- .../css-features/test/index.test.js | 64 +++++++- .../css-modules/test/index.test.js | 85 +++++++++-- test/integration/css/test/index.test.js | 141 ++++++++++++++---- .../scss-modules/test/index.test.js | 85 +++++++++-- test/integration/scss/test/index.test.js | 141 ++++++++++++++---- 6 files changed, 448 insertions(+), 101 deletions(-) diff --git a/test/integration/css-customization/test/index.test.js b/test/integration/css-customization/test/index.test.js index 2153553cb2e4889..b09141c5def77fe 100644 --- a/test/integration/css-customization/test/index.test.js +++ b/test/integration/css-customization/test/index.test.js @@ -16,8 +16,12 @@ describe('CSS Customization', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { code, stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've compiled and prefixed`, async () => { @@ -78,8 +82,12 @@ describe('Legacy Next-CSS Customization', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { code, stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've compiled and prefixed`, async () => { @@ -103,8 +111,12 @@ describe('CSS Customization Array', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { code, stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've compiled and prefixed`, async () => { @@ -168,9 +180,12 @@ describe('Bad CSS Customization', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - const { stderr } = await nextBuild(appDir, [], { stderr: true }) - + it('should compile successfully', async () => { + const { stdout, stderr } = await nextBuild(appDir, [], { + stdout: true, + stderr: true, + }) + expect(stdout).toMatch(/Compiled successfully/) expect(stderr).toMatch(/field which is not supported.*?sourceMap/) ;[ 'postcss-modules-values', diff --git a/test/integration/css-features/test/index.test.js b/test/integration/css-features/test/index.test.js index 3bdfc7f825a17a3..832783e879d0d25 100644 --- a/test/integration/css-features/test/index.test.js +++ b/test/integration/css-features/test/index.test.js @@ -11,9 +11,18 @@ const fixturesDir = join(__dirname, '../fixtures') describe('Browserslist: Old', () => { const appDir = join(fixturesDir, 'browsers-old') + let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + ;({ code, stdout } = await nextBuild(appDir, [], { + stdout: true, + })) + }) + + it('should have compiled successfully', () => { + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -34,9 +43,18 @@ describe('Browserslist: Old', () => { describe('Browserslist: New', () => { const appDir = join(fixturesDir, 'browsers-new') + let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + ;({ code, stdout } = await nextBuild(appDir, [], { + stdout: true, + })) + }) + + it('should have compiled successfully', () => { + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -57,9 +75,18 @@ describe('Browserslist: New', () => { describe('Custom Properties: Pass-Through IE11', () => { const appDir = join(fixturesDir, 'cp-ie-11') + let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + ;({ code, stdout } = await nextBuild(appDir, [], { + stdout: true, + })) + }) + + it('should have compiled successfully', () => { + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -80,9 +107,18 @@ describe('Custom Properties: Pass-Through IE11', () => { describe('Custom Properties: Pass-Through Modern', () => { const appDir = join(fixturesDir, 'cp-modern') + let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + ;({ code, stdout } = await nextBuild(appDir, [], { + stdout: true, + })) + }) + + it('should have compiled successfully', () => { + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -108,9 +144,10 @@ describe('Custom Properties: Fail for :root {} in CSS Modules', () => { }) it('should fail to build', async () => { - const { stderr } = await nextBuild(appDir, [], { + const { code, stderr } = await nextBuild(appDir, [], { stderr: true, }) + expect(code).not.toBe(0) expect(stderr).toContain('Failed to compile') expect(stderr).toContain('pages/styles.module.css') expect(stderr).toContain('CssSyntax error: Selector ":root" is not pure') @@ -125,9 +162,10 @@ describe('Custom Properties: Fail for global element in CSS Modules', () => { }) it('should fail to build', async () => { - const { stderr } = await nextBuild(appDir, [], { + const { code, stderr } = await nextBuild(appDir, [], { stderr: true, }) + expect(code).not.toBe(0) expect(stderr).toContain('Failed to compile') expect(stderr).toContain('pages/styles.module.css') expect(stderr).toContain('CssSyntax error: Selector "h1" is not pure') @@ -137,9 +175,18 @@ describe('Custom Properties: Fail for global element in CSS Modules', () => { describe('CSS Modules: Import Global CSS', () => { const appDir = join(fixturesDir, 'module-import-global') + let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + ;({ code, stdout } = await nextBuild(appDir, [], { + stdout: true, + })) + }) + + it('should have compiled successfully', () => { + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -165,9 +212,10 @@ describe('CSS Modules: Importing Invalid Global CSS', () => { }) it('should fail to build', async () => { - const { stderr } = await nextBuild(appDir, [], { + const { code, stderr } = await nextBuild(appDir, [], { stderr: true, }) + expect(code).not.toBe(0) expect(stderr).toContain('Failed to compile') expect(stderr).toContain('pages/styles.module.css') expect(stderr).toContain('CssSyntax error: Selector "a" is not pure') diff --git a/test/integration/css-modules/test/index.test.js b/test/integration/css-modules/test/index.test.js index e990a2e04624cb1..418c818a7ca19ba 100644 --- a/test/integration/css-modules/test/index.test.js +++ b/test/integration/css-modules/test/index.test.js @@ -23,9 +23,13 @@ describe('Basic CSS Module Support', () => { let appPort let app + let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + ;({ code, stdout } = await nextBuild(appDir, [], { + stdout: true, + })) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -33,6 +37,11 @@ describe('Basic CSS Module Support', () => { await killApp(app) }) + it('should have compiled successfully', () => { + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) + }) + it(`should've emitted a single CSS file`, async () => { const cssFolder = join(appDir, '.next/static/css') @@ -70,9 +79,13 @@ describe('3rd Party CSS Module Support', () => { let appPort let app + let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + ;({ code, stdout } = await nextBuild(appDir, [], { + stdout: true, + })) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -80,6 +93,11 @@ describe('3rd Party CSS Module Support', () => { await killApp(app) }) + it('should have compiled successfully', () => { + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) + }) + it(`should've emitted a single CSS file`, async () => { const cssFolder = join(appDir, '.next/static/css') @@ -141,9 +159,13 @@ describe('Has CSS Module in computed styles in Production', () => { let appPort let app + let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + ;({ code, stdout } = await nextBuild(appDir, [], { + stdout: true, + })) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -151,6 +173,11 @@ describe('Has CSS Module in computed styles in Production', () => { await killApp(app) }) + it('should have compiled successfully', () => { + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) + }) + it('should have CSS for page', async () => { const browser = await webdriver(appPort, '/') @@ -216,9 +243,10 @@ describe('Invalid CSS Module Usage in node_modules', () => { }) it('should fail to build', async () => { - const { stderr } = await nextBuild(appDir, [], { + const { code, stderr } = await nextBuild(appDir, [], { stderr: true, }) + expect(code).not.toBe(0) expect(stderr).toContain('Failed to compile') expect(stderr).toContain('node_modules/example/index.module.css') expect(stderr).toMatch( @@ -236,9 +264,10 @@ describe('Invalid CSS Module Usage in node_modules', () => { }) it('should fail to build', async () => { - const { stderr } = await nextBuild(appDir, [], { + const { code, stderr } = await nextBuild(appDir, [], { stderr: true, }) + expect(code).not.toBe(0) expect(stderr).toContain('Failed to compile') expect(stderr).toContain('node_modules/example/index.css') expect(stderr).toMatch( @@ -257,8 +286,13 @@ describe('Valid CSS Module Usage from within node_modules', () => { let appPort let app + let stdout + let code beforeAll(async () => { - await nextBuild(appDir) + await remove(join(appDir, '.next')) + ;({ code, stdout } = await nextBuild(appDir, [], { + stdout: true, + })) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -266,6 +300,11 @@ describe('Valid CSS Module Usage from within node_modules', () => { await killApp(app) }) + it('should have compiled successfully', () => { + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) + }) + it(`should've prerendered with relevant data`, async () => { const content = await renderViaHTTP(appPort, '/') const $ = cheerio.load(content) @@ -300,8 +339,13 @@ describe('Valid Nested CSS Module Usage from within node_modules', () => { let appPort let app + let stdout + let code beforeAll(async () => { - await nextBuild(appDir) + await remove(join(appDir, '.next')) + ;({ code, stdout } = await nextBuild(appDir, [], { + stdout: true, + })) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -309,6 +353,11 @@ describe('Valid Nested CSS Module Usage from within node_modules', () => { await killApp(app) }) + it('should have compiled successfully', () => { + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) + }) + it(`should've prerendered with relevant data`, async () => { const content = await renderViaHTTP(appPort, '/') const $ = cheerio.load(content) @@ -338,9 +387,18 @@ describe('CSS Module Composes Usage (Basic)', () => { // This is a very bad feature. Do not use it. const appDir = join(fixturesDir, 'composes-basic') + let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + ;({ code, stdout } = await nextBuild(appDir, [], { + stdout: true, + })) + }) + + it('should have compiled successfully', () => { + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -362,9 +420,18 @@ describe('CSS Module Composes Usage (External)', () => { // This is a very bad feature. Do not use it. const appDir = join(fixturesDir, 'composes-external') + let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + ;({ code, stdout } = await nextBuild(appDir, [], { + stdout: true, + })) + }) + + it('should have compiled successfully', () => { + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { diff --git a/test/integration/css/test/index.test.js b/test/integration/css/test/index.test.js index b4a971c74c934d9..45f85da1db0bcf2 100644 --- a/test/integration/css/test/index.test.js +++ b/test/integration/css/test/index.test.js @@ -28,8 +28,12 @@ describe('CSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { code, stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -52,8 +56,12 @@ describe('CSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { code, stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -76,8 +84,12 @@ describe('CSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { code, stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -101,8 +113,12 @@ describe('CSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { code, stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -128,8 +144,12 @@ describe('CSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { code, stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've compiled and prefixed`, async () => { @@ -187,8 +207,12 @@ describe('CSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { code, stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -213,9 +237,10 @@ describe('CSS Support', () => { }) it('should fail to build', async () => { - const { stderr } = await nextBuild(appDir, [], { + const { code, stderr } = await nextBuild(appDir, [], { stderr: true, }) + expect(code).not.toBe(0) expect(stderr).toContain('Failed to compile') expect(stderr).toContain('styles.module.css') expect(stderr).toMatch( @@ -233,9 +258,10 @@ describe('CSS Support', () => { }) it('should fail to build', async () => { - const { stderr } = await nextBuild(appDir, [], { + const { code, stderr } = await nextBuild(appDir, [], { stderr: true, }) + expect(code).not.toBe(0) expect(stderr).toContain('Failed to compile') expect(stderr).toContain('styles/global.css') expect(stderr).toMatch( @@ -253,9 +279,10 @@ describe('CSS Support', () => { }) it('should fail to build', async () => { - const { stderr } = await nextBuild(appDir, [], { + const { code, stderr } = await nextBuild(appDir, [], { stderr: true, }) + expect(code).not.toBe(0) expect(stderr).toContain('Failed to compile') expect(stderr).toContain('styles/global.css') expect(stderr).toMatch( @@ -273,9 +300,10 @@ describe('CSS Support', () => { }) it('should fail to build', async () => { - const { stderr } = await nextBuild(appDir, [], { + const { code, stderr } = await nextBuild(appDir, [], { stderr: true, }) + expect(code).not.toBe(0) expect(stderr).toContain('Failed to compile') expect(stderr).toContain('styles/global.css') expect(stderr).toContain('Please move all global CSS imports') @@ -448,9 +476,13 @@ describe('CSS Support', () => { let appPort let app + let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + ;({ code, stdout } = await nextBuild(appDir, [], { + stdout: true, + })) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -458,6 +490,11 @@ describe('CSS Support', () => { await killApp(app) }) + it('should have compiled successfully', () => { + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) + }) + it('should have CSS for page', async () => { const browser = await webdriver(appPort, '/page2') @@ -495,8 +532,12 @@ describe('CSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { code, stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted expected files`, async () => { @@ -540,8 +581,12 @@ describe('CSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { code, stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted expected files`, async () => { @@ -585,8 +630,12 @@ describe('CSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { code, stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted expected files`, async () => { @@ -630,8 +679,12 @@ describe('CSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { code, stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -653,8 +706,12 @@ describe('CSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { code, stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -679,8 +736,9 @@ describe('CSS Support', () => { }) it('should fail the build', async () => { - const { stderr } = await nextBuild(appDir, [], { stderr: true }) + const { code, stderr } = await nextBuild(appDir, [], { stderr: true }) + expect(code).not.toBe(0) expect(stderr).toMatch(/Can't resolve '[^']*?nprogress[^']*?'/) expect(stderr).toMatch(/Build error occurred/) }) @@ -715,9 +773,13 @@ describe('CSS Support', () => { let appPort let app + let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + ;({ code, stdout } = await nextBuild(appDir, [], { + stdout: true, + })) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -725,6 +787,11 @@ describe('CSS Support', () => { await killApp(app) }) + it('should have compiled successfully', () => { + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) + }) + it('should have the correct color (css ordering)', async () => { const browser = await webdriver(appPort, '/') @@ -742,8 +809,12 @@ describe('CSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { code, stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've compiled and prefixed`, async () => { @@ -779,8 +850,12 @@ describe('CSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { code, stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've compiled and prefixed`, async () => { diff --git a/test/integration/scss-modules/test/index.test.js b/test/integration/scss-modules/test/index.test.js index 751ef2e07889cfe..13b3c87f8ac5d94 100644 --- a/test/integration/scss-modules/test/index.test.js +++ b/test/integration/scss-modules/test/index.test.js @@ -23,9 +23,13 @@ describe('Basic SCSS Module Support', () => { let appPort let app + let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + ;({ code, stdout } = await nextBuild(appDir, [], { + stdout: true, + })) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -33,6 +37,11 @@ describe('Basic SCSS Module Support', () => { await killApp(app) }) + it('should have compiled successfully', () => { + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) + }) + it(`should've emitted a single CSS file`, async () => { const cssFolder = join(appDir, '.next/static/css') @@ -70,9 +79,13 @@ describe('3rd Party CSS Module Support', () => { let appPort let app + let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + ;({ code, stdout } = await nextBuild(appDir, [], { + stdout: true, + })) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -80,6 +93,11 @@ describe('3rd Party CSS Module Support', () => { await killApp(app) }) + it('should have compiled successfully', () => { + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) + }) + it(`should've emitted a single CSS file`, async () => { const cssFolder = join(appDir, '.next/static/css') @@ -141,9 +159,13 @@ describe('Has CSS Module in computed styles in Production', () => { let appPort let app + let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + ;({ code, stdout } = await nextBuild(appDir, [], { + stdout: true, + })) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -151,6 +173,11 @@ describe('Has CSS Module in computed styles in Production', () => { await killApp(app) }) + it('should have compiled successfully', () => { + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) + }) + it('should have CSS for page', async () => { const browser = await webdriver(appPort, '/') @@ -216,9 +243,10 @@ describe('Invalid CSS Module Usage in node_modules', () => { }) it('should fail to build', async () => { - const { stderr } = await nextBuild(appDir, [], { + const { code, stderr } = await nextBuild(appDir, [], { stderr: true, }) + expect(code).not.toBe(0) expect(stderr).toContain('Failed to compile') expect(stderr).toContain('node_modules/example/index.module.scss') expect(stderr).toMatch( @@ -236,9 +264,10 @@ describe('Invalid CSS Module Usage in node_modules', () => { }) it('should fail to build', async () => { - const { stderr } = await nextBuild(appDir, [], { + const { code, stderr } = await nextBuild(appDir, [], { stderr: true, }) + expect(code).not.toBe(0) expect(stderr).toContain('Failed to compile') expect(stderr).toContain('node_modules/example/index.scss') expect(stderr).toMatch( @@ -257,8 +286,13 @@ describe('Valid CSS Module Usage from within node_modules', () => { let appPort let app + let stdout + let code beforeAll(async () => { - await nextBuild(appDir) + await remove(join(appDir, '.next')) + ;({ code, stdout } = await nextBuild(appDir, [], { + stdout: true, + })) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -266,6 +300,11 @@ describe('Valid CSS Module Usage from within node_modules', () => { await killApp(app) }) + it('should have compiled successfully', () => { + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) + }) + it(`should've prerendered with relevant data`, async () => { const content = await renderViaHTTP(appPort, '/') const $ = cheerio.load(content) @@ -300,8 +339,13 @@ describe('Valid Nested CSS Module Usage from within node_modules', () => { let appPort let app + let stdout + let code beforeAll(async () => { - await nextBuild(appDir) + await remove(join(appDir, '.next')) + ;({ code, stdout } = await nextBuild(appDir, [], { + stdout: true, + })) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -309,6 +353,11 @@ describe('Valid Nested CSS Module Usage from within node_modules', () => { await killApp(app) }) + it('should have compiled successfully', () => { + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) + }) + it(`should've prerendered with relevant data`, async () => { const content = await renderViaHTTP(appPort, '/') const $ = cheerio.load(content) @@ -338,9 +387,18 @@ describe('CSS Module Composes Usage (Basic)', () => { // This is a very bad feature. Do not use it. const appDir = join(fixturesDir, 'composes-basic') + let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + ;({ code, stdout } = await nextBuild(appDir, [], { + stdout: true, + })) + }) + + it('should have compiled successfully', () => { + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -362,9 +420,18 @@ describe('CSS Module Composes Usage (External)', () => { // This is a very bad feature. Do not use it. const appDir = join(fixturesDir, 'composes-external') + let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + ;({ code, stdout } = await nextBuild(appDir, [], { + stdout: true, + })) + }) + + it('should have compiled successfully', () => { + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { diff --git a/test/integration/scss/test/index.test.js b/test/integration/scss/test/index.test.js index aca8a733f995191..d7dfd6b46b1c8d1 100644 --- a/test/integration/scss/test/index.test.js +++ b/test/integration/scss/test/index.test.js @@ -28,8 +28,12 @@ describe('SCSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { code, stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -52,8 +56,12 @@ describe('SCSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { code, stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -76,8 +84,12 @@ describe('SCSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { code, stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -101,8 +113,12 @@ describe('SCSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { code, stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -128,8 +144,12 @@ describe('SCSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { code, stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've compiled and prefixed`, async () => { @@ -188,8 +208,12 @@ describe('SCSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { code, stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -214,9 +238,10 @@ describe('SCSS Support', () => { }) it('should fail to build', async () => { - const { stderr } = await nextBuild(appDir, [], { + const { code, stderr } = await nextBuild(appDir, [], { stderr: true, }) + expect(code).not.toBe(0) expect(stderr).toContain('Failed to compile') expect(stderr).toContain('styles.module.scss') expect(stderr).toMatch( @@ -234,9 +259,10 @@ describe('SCSS Support', () => { }) it('should fail to build', async () => { - const { stderr } = await nextBuild(appDir, [], { + const { code, stderr } = await nextBuild(appDir, [], { stderr: true, }) + expect(code).not.toBe(0) expect(stderr).toContain('Failed to compile') expect(stderr).toContain('styles/global.scss') expect(stderr).toMatch( @@ -254,9 +280,10 @@ describe('SCSS Support', () => { }) it('should fail to build', async () => { - const { stderr } = await nextBuild(appDir, [], { + const { code, stderr } = await nextBuild(appDir, [], { stderr: true, }) + expect(code).not.toBe(0) expect(stderr).toContain('Failed to compile') expect(stderr).toContain('styles/global.scss') expect(stderr).toMatch( @@ -274,9 +301,10 @@ describe('SCSS Support', () => { }) it('should fail to build', async () => { - const { stderr } = await nextBuild(appDir, [], { + const { code, stderr } = await nextBuild(appDir, [], { stderr: true, }) + expect(code).not.toBe(0) expect(stderr).toContain('Failed to compile') expect(stderr).toContain('styles/global.scss') expect(stderr).toContain('Please move all global CSS imports') @@ -449,9 +477,13 @@ describe('SCSS Support', () => { let appPort let app + let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + ;({ code, stdout } = await nextBuild(appDir, [], { + stdout: true, + })) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -459,6 +491,11 @@ describe('SCSS Support', () => { await killApp(app) }) + it('should have compiled successfully', () => { + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) + }) + it('should have CSS for page', async () => { const browser = await webdriver(appPort, '/page2') @@ -496,8 +533,12 @@ describe('SCSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { code, stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted expected files`, async () => { @@ -541,8 +582,12 @@ describe('SCSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { code, stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted expected files`, async () => { @@ -586,8 +631,12 @@ describe('SCSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { code, stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted expected files`, async () => { @@ -631,8 +680,12 @@ describe('SCSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { code, stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -654,8 +707,12 @@ describe('SCSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { code, stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -680,8 +737,9 @@ describe('SCSS Support', () => { }) it('should fail the build', async () => { - const { stderr } = await nextBuild(appDir, [], { stderr: true }) + const { code, stderr } = await nextBuild(appDir, [], { stderr: true }) + expect(code).not.toBe(0) expect(stderr).toMatch(/Can't resolve '[^']*?nprogress[^']*?'/) expect(stderr).toMatch(/Build error occurred/) }) @@ -716,9 +774,13 @@ describe('SCSS Support', () => { let appPort let app + let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + ;({ code, stdout } = await nextBuild(appDir, [], { + stdout: true, + })) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -726,6 +788,11 @@ describe('SCSS Support', () => { await killApp(app) }) + it('should have compiled successfully', () => { + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) + }) + it('should have the correct color (css ordering)', async () => { const browser = await webdriver(appPort, '/') @@ -743,8 +810,12 @@ describe('SCSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { code, stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've compiled and prefixed`, async () => { @@ -780,8 +851,12 @@ describe('SCSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { code, stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(code).toBe(0) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've compiled and prefixed`, async () => {