From effde8595b01835f477d793afc038fc8a66ba651 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Thu, 23 Jan 2020 11:49:45 -0500 Subject: [PATCH 1/6] Check CSS Test Output --- .../css-customization/test/index.test.js | 30 ++++-- .../css-features/test/index.test.js | 5 +- test/integration/css/test/index.test.js | 101 +++++++++++++----- .../scss-modules/test/index.test.js | 35 ++++-- test/integration/scss/test/index.test.js | 101 +++++++++++++----- 5 files changed, 199 insertions(+), 73 deletions(-) diff --git a/test/integration/css-customization/test/index.test.js b/test/integration/css-customization/test/index.test.js index 2153553cb2e4889..c44681f82c4551f 100644 --- a/test/integration/css-customization/test/index.test.js +++ b/test/integration/css-customization/test/index.test.js @@ -16,8 +16,11 @@ describe('CSS Customization', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've compiled and prefixed`, async () => { @@ -78,8 +81,11 @@ describe('Legacy Next-CSS Customization', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've compiled and prefixed`, async () => { @@ -103,8 +109,11 @@ describe('CSS Customization Array', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've compiled and prefixed`, async () => { @@ -168,9 +177,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..24d0f54a16e40ae 100644 --- a/test/integration/css-features/test/index.test.js +++ b/test/integration/css-features/test/index.test.js @@ -13,7 +13,10 @@ describe('Browserslist: Old', () => { beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + 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..fa4c7548a4777ad 100644 --- a/test/integration/css/test/index.test.js +++ b/test/integration/css/test/index.test.js @@ -28,8 +28,11 @@ describe('CSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -52,8 +55,11 @@ describe('CSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -76,8 +82,11 @@ describe('CSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -101,8 +110,11 @@ describe('CSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -128,8 +140,11 @@ describe('CSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've compiled and prefixed`, async () => { @@ -187,8 +202,11 @@ describe('CSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -450,7 +468,10 @@ describe('CSS Support', () => { let app beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -495,8 +516,11 @@ describe('CSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted expected files`, async () => { @@ -540,8 +564,11 @@ describe('CSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted expected files`, async () => { @@ -585,8 +612,11 @@ describe('CSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted expected files`, async () => { @@ -630,8 +660,11 @@ describe('CSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -653,8 +686,11 @@ describe('CSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -717,7 +753,10 @@ describe('CSS Support', () => { let app beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -742,8 +781,11 @@ describe('CSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've compiled and prefixed`, async () => { @@ -779,8 +821,11 @@ describe('CSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + 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..575fa0bfce341a9 100644 --- a/test/integration/scss-modules/test/index.test.js +++ b/test/integration/scss-modules/test/index.test.js @@ -25,7 +25,10 @@ describe('Basic SCSS Module Support', () => { let app beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -72,7 +75,10 @@ describe('3rd Party CSS Module Support', () => { let app beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -143,7 +149,10 @@ describe('Has CSS Module in computed styles in Production', () => { let app beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -258,7 +267,10 @@ describe('Valid CSS Module Usage from within node_modules', () => { let appPort let app beforeAll(async () => { - await nextBuild(appDir) + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -301,7 +313,10 @@ describe('Valid Nested CSS Module Usage from within node_modules', () => { let appPort let app beforeAll(async () => { - await nextBuild(appDir) + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -340,7 +355,10 @@ describe('CSS Module Composes Usage (Basic)', () => { beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -364,7 +382,10 @@ describe('CSS Module Composes Usage (External)', () => { beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + 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..3150c36915e73f4 100644 --- a/test/integration/scss/test/index.test.js +++ b/test/integration/scss/test/index.test.js @@ -28,8 +28,11 @@ describe('SCSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -52,8 +55,11 @@ describe('SCSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -76,8 +82,11 @@ describe('SCSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -101,8 +110,11 @@ describe('SCSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -128,8 +140,11 @@ describe('SCSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've compiled and prefixed`, async () => { @@ -188,8 +203,11 @@ describe('SCSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -451,7 +469,10 @@ describe('SCSS Support', () => { let app beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -496,8 +517,11 @@ describe('SCSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted expected files`, async () => { @@ -541,8 +565,11 @@ describe('SCSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted expected files`, async () => { @@ -586,8 +613,11 @@ describe('SCSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted expected files`, async () => { @@ -631,8 +661,11 @@ describe('SCSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -654,8 +687,11 @@ describe('SCSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -718,7 +754,10 @@ describe('SCSS Support', () => { let app beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -743,8 +782,11 @@ describe('SCSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've compiled and prefixed`, async () => { @@ -780,8 +822,11 @@ describe('SCSS Support', () => { await remove(join(appDir, '.next')) }) - it('should build successfully', async () => { - await nextBuild(appDir) + it('should compile successfully', async () => { + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've compiled and prefixed`, async () => { From 13b51f2762aca751da16c70813132a98bb3c1070 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Thu, 23 Jan 2020 11:52:23 -0500 Subject: [PATCH 2/6] replace more --- .../css-features/test/index.test.js | 20 ++++++++--- .../css-modules/test/index.test.js | 35 +++++++++++++++---- 2 files changed, 44 insertions(+), 11 deletions(-) diff --git a/test/integration/css-features/test/index.test.js b/test/integration/css-features/test/index.test.js index 24d0f54a16e40ae..4445bff852c80d2 100644 --- a/test/integration/css-features/test/index.test.js +++ b/test/integration/css-features/test/index.test.js @@ -39,7 +39,10 @@ describe('Browserslist: New', () => { beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -62,7 +65,10 @@ describe('Custom Properties: Pass-Through IE11', () => { beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -85,7 +91,10 @@ describe('Custom Properties: Pass-Through Modern', () => { beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -142,7 +151,10 @@ describe('CSS Modules: Import Global CSS', () => { beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { diff --git a/test/integration/css-modules/test/index.test.js b/test/integration/css-modules/test/index.test.js index e990a2e04624cb1..17f5bc2318dcaf8 100644 --- a/test/integration/css-modules/test/index.test.js +++ b/test/integration/css-modules/test/index.test.js @@ -25,7 +25,10 @@ describe('Basic CSS Module Support', () => { let app beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -72,7 +75,10 @@ describe('3rd Party CSS Module Support', () => { let app beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -143,7 +149,10 @@ describe('Has CSS Module in computed styles in Production', () => { let app beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -258,7 +267,10 @@ describe('Valid CSS Module Usage from within node_modules', () => { let appPort let app beforeAll(async () => { - await nextBuild(appDir) + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -301,7 +313,10 @@ describe('Valid Nested CSS Module Usage from within node_modules', () => { let appPort let app beforeAll(async () => { - await nextBuild(appDir) + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -340,7 +355,10 @@ describe('CSS Module Composes Usage (Basic)', () => { beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { @@ -364,7 +382,10 @@ describe('CSS Module Composes Usage (External)', () => { beforeAll(async () => { await remove(join(appDir, '.next')) - await nextBuild(appDir) + const { stdout } = await nextBuild(appDir, [], { + stdout: true, + }) + expect(stdout).toMatch(/Compiled successfully/) }) it(`should've emitted a single CSS file`, async () => { From 6b4edaaf91914a945820ffa9e41b05a4f98788f5 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Thu, 23 Jan 2020 12:03:27 -0500 Subject: [PATCH 3/6] Fix tests --- .../css-features/test/index.test.js | 40 ++++++++--- .../css-modules/test/index.test.js | 68 +++++++++++++------ test/integration/css/test/index.test.js | 20 ++++-- .../scss-modules/test/index.test.js | 68 +++++++++++++------ test/integration/scss/test/index.test.js | 20 ++++-- 5 files changed, 156 insertions(+), 60 deletions(-) diff --git a/test/integration/css-features/test/index.test.js b/test/integration/css-features/test/index.test.js index 4445bff852c80d2..6ab18580880c590 100644 --- a/test/integration/css-features/test/index.test.js +++ b/test/integration/css-features/test/index.test.js @@ -11,11 +11,15 @@ const fixturesDir = join(__dirname, '../fixtures') describe('Browserslist: Old', () => { const appDir = join(fixturesDir, 'browsers-old') + let stdout beforeAll(async () => { await remove(join(appDir, '.next')) - const { stdout } = await nextBuild(appDir, [], { + ;({ stdout } = await nextBuild(appDir, [], { stdout: true, - }) + })) + }) + + it('should have compiled successfully', () => { expect(stdout).toMatch(/Compiled successfully/) }) @@ -37,11 +41,15 @@ describe('Browserslist: Old', () => { describe('Browserslist: New', () => { const appDir = join(fixturesDir, 'browsers-new') + let stdout beforeAll(async () => { await remove(join(appDir, '.next')) - const { stdout } = await nextBuild(appDir, [], { + ;({ stdout } = await nextBuild(appDir, [], { stdout: true, - }) + })) + }) + + it('should have compiled successfully', () => { expect(stdout).toMatch(/Compiled successfully/) }) @@ -63,11 +71,15 @@ describe('Browserslist: New', () => { describe('Custom Properties: Pass-Through IE11', () => { const appDir = join(fixturesDir, 'cp-ie-11') + let stdout beforeAll(async () => { await remove(join(appDir, '.next')) - const { stdout } = await nextBuild(appDir, [], { + ;({ stdout } = await nextBuild(appDir, [], { stdout: true, - }) + })) + }) + + it('should have compiled successfully', () => { expect(stdout).toMatch(/Compiled successfully/) }) @@ -89,11 +101,15 @@ describe('Custom Properties: Pass-Through IE11', () => { describe('Custom Properties: Pass-Through Modern', () => { const appDir = join(fixturesDir, 'cp-modern') + let stdout beforeAll(async () => { await remove(join(appDir, '.next')) - const { stdout } = await nextBuild(appDir, [], { + ;({ stdout } = await nextBuild(appDir, [], { stdout: true, - }) + })) + }) + + it('should have compiled successfully', () => { expect(stdout).toMatch(/Compiled successfully/) }) @@ -149,11 +165,15 @@ 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 beforeAll(async () => { await remove(join(appDir, '.next')) - const { stdout } = await nextBuild(appDir, [], { + ;({ stdout } = await nextBuild(appDir, [], { stdout: true, - }) + })) + }) + + it('should have compiled successfully', () => { expect(stdout).toMatch(/Compiled successfully/) }) diff --git a/test/integration/css-modules/test/index.test.js b/test/integration/css-modules/test/index.test.js index 17f5bc2318dcaf8..062a568f299e0ed 100644 --- a/test/integration/css-modules/test/index.test.js +++ b/test/integration/css-modules/test/index.test.js @@ -23,12 +23,12 @@ describe('Basic CSS Module Support', () => { let appPort let app + let stdout beforeAll(async () => { await remove(join(appDir, '.next')) - const { stdout } = await nextBuild(appDir, [], { + ;({ stdout } = await nextBuild(appDir, [], { stdout: true, - }) - expect(stdout).toMatch(/Compiled successfully/) + })) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -36,6 +36,10 @@ describe('Basic CSS Module Support', () => { await killApp(app) }) + it('should have compiled successfully', () => { + expect(stdout).toMatch(/Compiled successfully/) + }) + it(`should've emitted a single CSS file`, async () => { const cssFolder = join(appDir, '.next/static/css') @@ -73,12 +77,12 @@ describe('3rd Party CSS Module Support', () => { let appPort let app + let stdout beforeAll(async () => { await remove(join(appDir, '.next')) - const { stdout } = await nextBuild(appDir, [], { + ;({ stdout } = await nextBuild(appDir, [], { stdout: true, - }) - expect(stdout).toMatch(/Compiled successfully/) + })) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -86,6 +90,10 @@ describe('3rd Party CSS Module Support', () => { await killApp(app) }) + it('should have compiled successfully', () => { + expect(stdout).toMatch(/Compiled successfully/) + }) + it(`should've emitted a single CSS file`, async () => { const cssFolder = join(appDir, '.next/static/css') @@ -147,12 +155,12 @@ describe('Has CSS Module in computed styles in Production', () => { let appPort let app + let stdout beforeAll(async () => { await remove(join(appDir, '.next')) - const { stdout } = await nextBuild(appDir, [], { + ;({ stdout } = await nextBuild(appDir, [], { stdout: true, - }) - expect(stdout).toMatch(/Compiled successfully/) + })) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -160,6 +168,10 @@ describe('Has CSS Module in computed styles in Production', () => { await killApp(app) }) + it('should have compiled successfully', () => { + expect(stdout).toMatch(/Compiled successfully/) + }) + it('should have CSS for page', async () => { const browser = await webdriver(appPort, '/') @@ -266,11 +278,12 @@ describe('Valid CSS Module Usage from within node_modules', () => { let appPort let app + let stdout beforeAll(async () => { - const { stdout } = await nextBuild(appDir, [], { + await remove(join(appDir, '.next')) + ;({ stdout } = await nextBuild(appDir, [], { stdout: true, - }) - expect(stdout).toMatch(/Compiled successfully/) + })) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -278,6 +291,10 @@ describe('Valid CSS Module Usage from within node_modules', () => { await killApp(app) }) + it('should have compiled successfully', () => { + expect(stdout).toMatch(/Compiled successfully/) + }) + it(`should've prerendered with relevant data`, async () => { const content = await renderViaHTTP(appPort, '/') const $ = cheerio.load(content) @@ -312,11 +329,12 @@ describe('Valid Nested CSS Module Usage from within node_modules', () => { let appPort let app + let stdout beforeAll(async () => { - const { stdout } = await nextBuild(appDir, [], { + await remove(join(appDir, '.next')) + ;({ stdout } = await nextBuild(appDir, [], { stdout: true, - }) - expect(stdout).toMatch(/Compiled successfully/) + })) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -324,6 +342,10 @@ describe('Valid Nested CSS Module Usage from within node_modules', () => { await killApp(app) }) + it('should have compiled successfully', () => { + expect(stdout).toMatch(/Compiled successfully/) + }) + it(`should've prerendered with relevant data`, async () => { const content = await renderViaHTTP(appPort, '/') const $ = cheerio.load(content) @@ -353,11 +375,15 @@ describe('CSS Module Composes Usage (Basic)', () => { // This is a very bad feature. Do not use it. const appDir = join(fixturesDir, 'composes-basic') + let stdout beforeAll(async () => { await remove(join(appDir, '.next')) - const { stdout } = await nextBuild(appDir, [], { + ;({ stdout } = await nextBuild(appDir, [], { stdout: true, - }) + })) + }) + + it('should have compiled successfully', () => { expect(stdout).toMatch(/Compiled successfully/) }) @@ -380,11 +406,15 @@ describe('CSS Module Composes Usage (External)', () => { // This is a very bad feature. Do not use it. const appDir = join(fixturesDir, 'composes-external') + let stdout beforeAll(async () => { await remove(join(appDir, '.next')) - const { stdout } = await nextBuild(appDir, [], { + ;({ stdout } = await nextBuild(appDir, [], { stdout: true, - }) + })) + }) + + it('should have compiled successfully', () => { expect(stdout).toMatch(/Compiled successfully/) }) diff --git a/test/integration/css/test/index.test.js b/test/integration/css/test/index.test.js index fa4c7548a4777ad..ceb999f18bf78af 100644 --- a/test/integration/css/test/index.test.js +++ b/test/integration/css/test/index.test.js @@ -466,12 +466,12 @@ describe('CSS Support', () => { let appPort let app + let stdout beforeAll(async () => { await remove(join(appDir, '.next')) - const { stdout } = await nextBuild(appDir, [], { + ;({ stdout } = await nextBuild(appDir, [], { stdout: true, - }) - expect(stdout).toMatch(/Compiled successfully/) + })) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -479,6 +479,10 @@ describe('CSS Support', () => { await killApp(app) }) + it('should have compiled successfully', () => { + expect(stdout).toMatch(/Compiled successfully/) + }) + it('should have CSS for page', async () => { const browser = await webdriver(appPort, '/page2') @@ -751,12 +755,12 @@ describe('CSS Support', () => { let appPort let app + let stdout beforeAll(async () => { await remove(join(appDir, '.next')) - const { stdout } = await nextBuild(appDir, [], { + ;({ stdout } = await nextBuild(appDir, [], { stdout: true, - }) - expect(stdout).toMatch(/Compiled successfully/) + })) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -764,6 +768,10 @@ describe('CSS Support', () => { await killApp(app) }) + it('should have compiled successfully', () => { + expect(stdout).toMatch(/Compiled successfully/) + }) + it('should have the correct color (css ordering)', async () => { const browser = await webdriver(appPort, '/') diff --git a/test/integration/scss-modules/test/index.test.js b/test/integration/scss-modules/test/index.test.js index 575fa0bfce341a9..fbccdfb1d34215b 100644 --- a/test/integration/scss-modules/test/index.test.js +++ b/test/integration/scss-modules/test/index.test.js @@ -23,12 +23,12 @@ describe('Basic SCSS Module Support', () => { let appPort let app + let stdout beforeAll(async () => { await remove(join(appDir, '.next')) - const { stdout } = await nextBuild(appDir, [], { + ;({ stdout } = await nextBuild(appDir, [], { stdout: true, - }) - expect(stdout).toMatch(/Compiled successfully/) + })) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -36,6 +36,10 @@ describe('Basic SCSS Module Support', () => { await killApp(app) }) + it('should have compiled successfully', () => { + expect(stdout).toMatch(/Compiled successfully/) + }) + it(`should've emitted a single CSS file`, async () => { const cssFolder = join(appDir, '.next/static/css') @@ -73,12 +77,12 @@ describe('3rd Party CSS Module Support', () => { let appPort let app + let stdout beforeAll(async () => { await remove(join(appDir, '.next')) - const { stdout } = await nextBuild(appDir, [], { + ;({ stdout } = await nextBuild(appDir, [], { stdout: true, - }) - expect(stdout).toMatch(/Compiled successfully/) + })) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -86,6 +90,10 @@ describe('3rd Party CSS Module Support', () => { await killApp(app) }) + it('should have compiled successfully', () => { + expect(stdout).toMatch(/Compiled successfully/) + }) + it(`should've emitted a single CSS file`, async () => { const cssFolder = join(appDir, '.next/static/css') @@ -147,12 +155,12 @@ describe('Has CSS Module in computed styles in Production', () => { let appPort let app + let stdout beforeAll(async () => { await remove(join(appDir, '.next')) - const { stdout } = await nextBuild(appDir, [], { + ;({ stdout } = await nextBuild(appDir, [], { stdout: true, - }) - expect(stdout).toMatch(/Compiled successfully/) + })) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -160,6 +168,10 @@ describe('Has CSS Module in computed styles in Production', () => { await killApp(app) }) + it('should have compiled successfully', () => { + expect(stdout).toMatch(/Compiled successfully/) + }) + it('should have CSS for page', async () => { const browser = await webdriver(appPort, '/') @@ -266,11 +278,12 @@ describe('Valid CSS Module Usage from within node_modules', () => { let appPort let app + let stdout beforeAll(async () => { - const { stdout } = await nextBuild(appDir, [], { + await remove(join(appDir, '.next')) + ;({ stdout } = await nextBuild(appDir, [], { stdout: true, - }) - expect(stdout).toMatch(/Compiled successfully/) + })) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -278,6 +291,10 @@ describe('Valid CSS Module Usage from within node_modules', () => { await killApp(app) }) + it('should have compiled successfully', () => { + expect(stdout).toMatch(/Compiled successfully/) + }) + it(`should've prerendered with relevant data`, async () => { const content = await renderViaHTTP(appPort, '/') const $ = cheerio.load(content) @@ -312,11 +329,12 @@ describe('Valid Nested CSS Module Usage from within node_modules', () => { let appPort let app + let stdout beforeAll(async () => { - const { stdout } = await nextBuild(appDir, [], { + await remove(join(appDir, '.next')) + ;({ stdout } = await nextBuild(appDir, [], { stdout: true, - }) - expect(stdout).toMatch(/Compiled successfully/) + })) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -324,6 +342,10 @@ describe('Valid Nested CSS Module Usage from within node_modules', () => { await killApp(app) }) + it('should have compiled successfully', () => { + expect(stdout).toMatch(/Compiled successfully/) + }) + it(`should've prerendered with relevant data`, async () => { const content = await renderViaHTTP(appPort, '/') const $ = cheerio.load(content) @@ -353,11 +375,15 @@ describe('CSS Module Composes Usage (Basic)', () => { // This is a very bad feature. Do not use it. const appDir = join(fixturesDir, 'composes-basic') + let stdout beforeAll(async () => { await remove(join(appDir, '.next')) - const { stdout } = await nextBuild(appDir, [], { + ;({ stdout } = await nextBuild(appDir, [], { stdout: true, - }) + })) + }) + + it('should have compiled successfully', () => { expect(stdout).toMatch(/Compiled successfully/) }) @@ -380,11 +406,15 @@ describe('CSS Module Composes Usage (External)', () => { // This is a very bad feature. Do not use it. const appDir = join(fixturesDir, 'composes-external') + let stdout beforeAll(async () => { await remove(join(appDir, '.next')) - const { stdout } = await nextBuild(appDir, [], { + ;({ stdout } = await nextBuild(appDir, [], { stdout: true, - }) + })) + }) + + it('should have compiled successfully', () => { expect(stdout).toMatch(/Compiled successfully/) }) diff --git a/test/integration/scss/test/index.test.js b/test/integration/scss/test/index.test.js index 3150c36915e73f4..001c3a1ce5db565 100644 --- a/test/integration/scss/test/index.test.js +++ b/test/integration/scss/test/index.test.js @@ -467,12 +467,12 @@ describe('SCSS Support', () => { let appPort let app + let stdout beforeAll(async () => { await remove(join(appDir, '.next')) - const { stdout } = await nextBuild(appDir, [], { + ;({ stdout } = await nextBuild(appDir, [], { stdout: true, - }) - expect(stdout).toMatch(/Compiled successfully/) + })) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -480,6 +480,10 @@ describe('SCSS Support', () => { await killApp(app) }) + it('should have compiled successfully', () => { + expect(stdout).toMatch(/Compiled successfully/) + }) + it('should have CSS for page', async () => { const browser = await webdriver(appPort, '/page2') @@ -752,12 +756,12 @@ describe('SCSS Support', () => { let appPort let app + let stdout beforeAll(async () => { await remove(join(appDir, '.next')) - const { stdout } = await nextBuild(appDir, [], { + ;({ stdout } = await nextBuild(appDir, [], { stdout: true, - }) - expect(stdout).toMatch(/Compiled successfully/) + })) appPort = await findPort() app = await nextStart(appDir, appPort) }) @@ -765,6 +769,10 @@ describe('SCSS Support', () => { await killApp(app) }) + it('should have compiled successfully', () => { + expect(stdout).toMatch(/Compiled successfully/) + }) + it('should have the correct color (css ordering)', async () => { const browser = await webdriver(appPort, '/') From 54168721b0d294e8d5bd6d0ba232abb1f4167841 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Thu, 23 Jan 2020 12:07:03 -0500 Subject: [PATCH 4/6] check code --- test/integration/css-customization/test/index.test.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/integration/css-customization/test/index.test.js b/test/integration/css-customization/test/index.test.js index c44681f82c4551f..b09141c5def77fe 100644 --- a/test/integration/css-customization/test/index.test.js +++ b/test/integration/css-customization/test/index.test.js @@ -17,9 +17,10 @@ describe('CSS Customization', () => { }) it('should compile successfully', async () => { - const { stdout } = await nextBuild(appDir, [], { + const { code, stdout } = await nextBuild(appDir, [], { stdout: true, }) + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -82,9 +83,10 @@ describe('Legacy Next-CSS Customization', () => { }) it('should compile successfully', async () => { - const { stdout } = await nextBuild(appDir, [], { + const { code, stdout } = await nextBuild(appDir, [], { stdout: true, }) + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -110,9 +112,10 @@ describe('CSS Customization Array', () => { }) it('should compile successfully', async () => { - const { stdout } = await nextBuild(appDir, [], { + const { code, stdout } = await nextBuild(appDir, [], { stdout: true, }) + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) From 271d3ff2097e05a81923691ec093e53d3ca83fcf Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Thu, 23 Jan 2020 12:11:36 -0500 Subject: [PATCH 5/6] Add code check --- test/integration/css/test/index.test.js | 62 +++++++++++++++++-------- 1 file changed, 42 insertions(+), 20 deletions(-) diff --git a/test/integration/css/test/index.test.js b/test/integration/css/test/index.test.js index ceb999f18bf78af..45f85da1db0bcf2 100644 --- a/test/integration/css/test/index.test.js +++ b/test/integration/css/test/index.test.js @@ -29,9 +29,10 @@ describe('CSS Support', () => { }) it('should compile successfully', async () => { - const { stdout } = await nextBuild(appDir, [], { + const { code, stdout } = await nextBuild(appDir, [], { stdout: true, }) + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -56,9 +57,10 @@ describe('CSS Support', () => { }) it('should compile successfully', async () => { - const { stdout } = await nextBuild(appDir, [], { + const { code, stdout } = await nextBuild(appDir, [], { stdout: true, }) + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -83,9 +85,10 @@ describe('CSS Support', () => { }) it('should compile successfully', async () => { - const { stdout } = await nextBuild(appDir, [], { + const { code, stdout } = await nextBuild(appDir, [], { stdout: true, }) + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -111,9 +114,10 @@ describe('CSS Support', () => { }) it('should compile successfully', async () => { - const { stdout } = await nextBuild(appDir, [], { + const { code, stdout } = await nextBuild(appDir, [], { stdout: true, }) + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -141,9 +145,10 @@ describe('CSS Support', () => { }) it('should compile successfully', async () => { - const { stdout } = await nextBuild(appDir, [], { + const { code, stdout } = await nextBuild(appDir, [], { stdout: true, }) + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -203,9 +208,10 @@ describe('CSS Support', () => { }) it('should compile successfully', async () => { - const { stdout } = await nextBuild(appDir, [], { + const { code, stdout } = await nextBuild(appDir, [], { stdout: true, }) + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -231,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( @@ -251,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( @@ -271,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( @@ -291,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') @@ -467,9 +477,10 @@ describe('CSS Support', () => { let appPort let app let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - ;({ stdout } = await nextBuild(appDir, [], { + ;({ code, stdout } = await nextBuild(appDir, [], { stdout: true, })) appPort = await findPort() @@ -480,6 +491,7 @@ describe('CSS Support', () => { }) it('should have compiled successfully', () => { + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -521,9 +533,10 @@ describe('CSS Support', () => { }) it('should compile successfully', async () => { - const { stdout } = await nextBuild(appDir, [], { + const { code, stdout } = await nextBuild(appDir, [], { stdout: true, }) + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -569,9 +582,10 @@ describe('CSS Support', () => { }) it('should compile successfully', async () => { - const { stdout } = await nextBuild(appDir, [], { + const { code, stdout } = await nextBuild(appDir, [], { stdout: true, }) + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -617,9 +631,10 @@ describe('CSS Support', () => { }) it('should compile successfully', async () => { - const { stdout } = await nextBuild(appDir, [], { + const { code, stdout } = await nextBuild(appDir, [], { stdout: true, }) + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -665,9 +680,10 @@ describe('CSS Support', () => { }) it('should compile successfully', async () => { - const { stdout } = await nextBuild(appDir, [], { + const { code, stdout } = await nextBuild(appDir, [], { stdout: true, }) + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -691,9 +707,10 @@ describe('CSS Support', () => { }) it('should compile successfully', async () => { - const { stdout } = await nextBuild(appDir, [], { + const { code, stdout } = await nextBuild(appDir, [], { stdout: true, }) + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -719,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/) }) @@ -756,9 +774,10 @@ describe('CSS Support', () => { let appPort let app let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - ;({ stdout } = await nextBuild(appDir, [], { + ;({ code, stdout } = await nextBuild(appDir, [], { stdout: true, })) appPort = await findPort() @@ -769,6 +788,7 @@ describe('CSS Support', () => { }) it('should have compiled successfully', () => { + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -790,9 +810,10 @@ describe('CSS Support', () => { }) it('should compile successfully', async () => { - const { stdout } = await nextBuild(appDir, [], { + const { code, stdout } = await nextBuild(appDir, [], { stdout: true, }) + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -830,9 +851,10 @@ describe('CSS Support', () => { }) it('should compile successfully', async () => { - const { stdout } = await nextBuild(appDir, [], { + const { code, stdout } = await nextBuild(appDir, [], { stdout: true, }) + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) From 95fc6912a4c6ffb1d94872d6c1284c43e6beac70 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Thu, 23 Jan 2020 12:20:24 -0500 Subject: [PATCH 6/6] Check codes everywhere --- .../css-features/test/index.test.js | 29 ++++++--- .../css-modules/test/index.test.js | 34 +++++++--- .../scss-modules/test/index.test.js | 34 +++++++--- test/integration/scss/test/index.test.js | 62 +++++++++++++------ 4 files changed, 113 insertions(+), 46 deletions(-) diff --git a/test/integration/css-features/test/index.test.js b/test/integration/css-features/test/index.test.js index 6ab18580880c590..832783e879d0d25 100644 --- a/test/integration/css-features/test/index.test.js +++ b/test/integration/css-features/test/index.test.js @@ -12,14 +12,16 @@ describe('Browserslist: Old', () => { const appDir = join(fixturesDir, 'browsers-old') let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - ;({ stdout } = await nextBuild(appDir, [], { + ;({ code, stdout } = await nextBuild(appDir, [], { stdout: true, })) }) it('should have compiled successfully', () => { + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -42,14 +44,16 @@ describe('Browserslist: New', () => { const appDir = join(fixturesDir, 'browsers-new') let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - ;({ stdout } = await nextBuild(appDir, [], { + ;({ code, stdout } = await nextBuild(appDir, [], { stdout: true, })) }) it('should have compiled successfully', () => { + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -72,14 +76,16 @@ describe('Custom Properties: Pass-Through IE11', () => { const appDir = join(fixturesDir, 'cp-ie-11') let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - ;({ stdout } = await nextBuild(appDir, [], { + ;({ code, stdout } = await nextBuild(appDir, [], { stdout: true, })) }) it('should have compiled successfully', () => { + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -102,14 +108,16 @@ describe('Custom Properties: Pass-Through Modern', () => { const appDir = join(fixturesDir, 'cp-modern') let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - ;({ stdout } = await nextBuild(appDir, [], { + ;({ code, stdout } = await nextBuild(appDir, [], { stdout: true, })) }) it('should have compiled successfully', () => { + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -136,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') @@ -153,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') @@ -166,14 +176,16 @@ describe('CSS Modules: Import Global CSS', () => { const appDir = join(fixturesDir, 'module-import-global') let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - ;({ stdout } = await nextBuild(appDir, [], { + ;({ code, stdout } = await nextBuild(appDir, [], { stdout: true, })) }) it('should have compiled successfully', () => { + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -200,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 062a568f299e0ed..418c818a7ca19ba 100644 --- a/test/integration/css-modules/test/index.test.js +++ b/test/integration/css-modules/test/index.test.js @@ -24,9 +24,10 @@ describe('Basic CSS Module Support', () => { let appPort let app let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - ;({ stdout } = await nextBuild(appDir, [], { + ;({ code, stdout } = await nextBuild(appDir, [], { stdout: true, })) appPort = await findPort() @@ -37,6 +38,7 @@ describe('Basic CSS Module Support', () => { }) it('should have compiled successfully', () => { + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -78,9 +80,10 @@ describe('3rd Party CSS Module Support', () => { let appPort let app let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - ;({ stdout } = await nextBuild(appDir, [], { + ;({ code, stdout } = await nextBuild(appDir, [], { stdout: true, })) appPort = await findPort() @@ -91,6 +94,7 @@ describe('3rd Party CSS Module Support', () => { }) it('should have compiled successfully', () => { + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -156,9 +160,10 @@ describe('Has CSS Module in computed styles in Production', () => { let appPort let app let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - ;({ stdout } = await nextBuild(appDir, [], { + ;({ code, stdout } = await nextBuild(appDir, [], { stdout: true, })) appPort = await findPort() @@ -169,6 +174,7 @@ describe('Has CSS Module in computed styles in Production', () => { }) it('should have compiled successfully', () => { + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -237,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( @@ -257,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( @@ -279,9 +287,10 @@ describe('Valid CSS Module Usage from within node_modules', () => { let appPort let app let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - ;({ stdout } = await nextBuild(appDir, [], { + ;({ code, stdout } = await nextBuild(appDir, [], { stdout: true, })) appPort = await findPort() @@ -292,6 +301,7 @@ describe('Valid CSS Module Usage from within node_modules', () => { }) it('should have compiled successfully', () => { + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -330,9 +340,10 @@ describe('Valid Nested CSS Module Usage from within node_modules', () => { let appPort let app let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - ;({ stdout } = await nextBuild(appDir, [], { + ;({ code, stdout } = await nextBuild(appDir, [], { stdout: true, })) appPort = await findPort() @@ -343,6 +354,7 @@ describe('Valid Nested CSS Module Usage from within node_modules', () => { }) it('should have compiled successfully', () => { + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -376,14 +388,16 @@ describe('CSS Module Composes Usage (Basic)', () => { const appDir = join(fixturesDir, 'composes-basic') let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - ;({ stdout } = await nextBuild(appDir, [], { + ;({ code, stdout } = await nextBuild(appDir, [], { stdout: true, })) }) it('should have compiled successfully', () => { + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -407,14 +421,16 @@ describe('CSS Module Composes Usage (External)', () => { const appDir = join(fixturesDir, 'composes-external') let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - ;({ stdout } = await nextBuild(appDir, [], { + ;({ code, stdout } = await nextBuild(appDir, [], { stdout: true, })) }) it('should have compiled successfully', () => { + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) diff --git a/test/integration/scss-modules/test/index.test.js b/test/integration/scss-modules/test/index.test.js index fbccdfb1d34215b..13b3c87f8ac5d94 100644 --- a/test/integration/scss-modules/test/index.test.js +++ b/test/integration/scss-modules/test/index.test.js @@ -24,9 +24,10 @@ describe('Basic SCSS Module Support', () => { let appPort let app let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - ;({ stdout } = await nextBuild(appDir, [], { + ;({ code, stdout } = await nextBuild(appDir, [], { stdout: true, })) appPort = await findPort() @@ -37,6 +38,7 @@ describe('Basic SCSS Module Support', () => { }) it('should have compiled successfully', () => { + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -78,9 +80,10 @@ describe('3rd Party CSS Module Support', () => { let appPort let app let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - ;({ stdout } = await nextBuild(appDir, [], { + ;({ code, stdout } = await nextBuild(appDir, [], { stdout: true, })) appPort = await findPort() @@ -91,6 +94,7 @@ describe('3rd Party CSS Module Support', () => { }) it('should have compiled successfully', () => { + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -156,9 +160,10 @@ describe('Has CSS Module in computed styles in Production', () => { let appPort let app let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - ;({ stdout } = await nextBuild(appDir, [], { + ;({ code, stdout } = await nextBuild(appDir, [], { stdout: true, })) appPort = await findPort() @@ -169,6 +174,7 @@ describe('Has CSS Module in computed styles in Production', () => { }) it('should have compiled successfully', () => { + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -237,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( @@ -257,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( @@ -279,9 +287,10 @@ describe('Valid CSS Module Usage from within node_modules', () => { let appPort let app let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - ;({ stdout } = await nextBuild(appDir, [], { + ;({ code, stdout } = await nextBuild(appDir, [], { stdout: true, })) appPort = await findPort() @@ -292,6 +301,7 @@ describe('Valid CSS Module Usage from within node_modules', () => { }) it('should have compiled successfully', () => { + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -330,9 +340,10 @@ describe('Valid Nested CSS Module Usage from within node_modules', () => { let appPort let app let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - ;({ stdout } = await nextBuild(appDir, [], { + ;({ code, stdout } = await nextBuild(appDir, [], { stdout: true, })) appPort = await findPort() @@ -343,6 +354,7 @@ describe('Valid Nested CSS Module Usage from within node_modules', () => { }) it('should have compiled successfully', () => { + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -376,14 +388,16 @@ describe('CSS Module Composes Usage (Basic)', () => { const appDir = join(fixturesDir, 'composes-basic') let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - ;({ stdout } = await nextBuild(appDir, [], { + ;({ code, stdout } = await nextBuild(appDir, [], { stdout: true, })) }) it('should have compiled successfully', () => { + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -407,14 +421,16 @@ describe('CSS Module Composes Usage (External)', () => { const appDir = join(fixturesDir, 'composes-external') let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - ;({ stdout } = await nextBuild(appDir, [], { + ;({ code, stdout } = await nextBuild(appDir, [], { stdout: true, })) }) it('should have compiled successfully', () => { + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) diff --git a/test/integration/scss/test/index.test.js b/test/integration/scss/test/index.test.js index 001c3a1ce5db565..d7dfd6b46b1c8d1 100644 --- a/test/integration/scss/test/index.test.js +++ b/test/integration/scss/test/index.test.js @@ -29,9 +29,10 @@ describe('SCSS Support', () => { }) it('should compile successfully', async () => { - const { stdout } = await nextBuild(appDir, [], { + const { code, stdout } = await nextBuild(appDir, [], { stdout: true, }) + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -56,9 +57,10 @@ describe('SCSS Support', () => { }) it('should compile successfully', async () => { - const { stdout } = await nextBuild(appDir, [], { + const { code, stdout } = await nextBuild(appDir, [], { stdout: true, }) + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -83,9 +85,10 @@ describe('SCSS Support', () => { }) it('should compile successfully', async () => { - const { stdout } = await nextBuild(appDir, [], { + const { code, stdout } = await nextBuild(appDir, [], { stdout: true, }) + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -111,9 +114,10 @@ describe('SCSS Support', () => { }) it('should compile successfully', async () => { - const { stdout } = await nextBuild(appDir, [], { + const { code, stdout } = await nextBuild(appDir, [], { stdout: true, }) + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -141,9 +145,10 @@ describe('SCSS Support', () => { }) it('should compile successfully', async () => { - const { stdout } = await nextBuild(appDir, [], { + const { code, stdout } = await nextBuild(appDir, [], { stdout: true, }) + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -204,9 +209,10 @@ describe('SCSS Support', () => { }) it('should compile successfully', async () => { - const { stdout } = await nextBuild(appDir, [], { + const { code, stdout } = await nextBuild(appDir, [], { stdout: true, }) + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -232,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( @@ -252,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( @@ -272,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( @@ -292,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') @@ -468,9 +478,10 @@ describe('SCSS Support', () => { let appPort let app let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - ;({ stdout } = await nextBuild(appDir, [], { + ;({ code, stdout } = await nextBuild(appDir, [], { stdout: true, })) appPort = await findPort() @@ -481,6 +492,7 @@ describe('SCSS Support', () => { }) it('should have compiled successfully', () => { + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -522,9 +534,10 @@ describe('SCSS Support', () => { }) it('should compile successfully', async () => { - const { stdout } = await nextBuild(appDir, [], { + const { code, stdout } = await nextBuild(appDir, [], { stdout: true, }) + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -570,9 +583,10 @@ describe('SCSS Support', () => { }) it('should compile successfully', async () => { - const { stdout } = await nextBuild(appDir, [], { + const { code, stdout } = await nextBuild(appDir, [], { stdout: true, }) + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -618,9 +632,10 @@ describe('SCSS Support', () => { }) it('should compile successfully', async () => { - const { stdout } = await nextBuild(appDir, [], { + const { code, stdout } = await nextBuild(appDir, [], { stdout: true, }) + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -666,9 +681,10 @@ describe('SCSS Support', () => { }) it('should compile successfully', async () => { - const { stdout } = await nextBuild(appDir, [], { + const { code, stdout } = await nextBuild(appDir, [], { stdout: true, }) + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -692,9 +708,10 @@ describe('SCSS Support', () => { }) it('should compile successfully', async () => { - const { stdout } = await nextBuild(appDir, [], { + const { code, stdout } = await nextBuild(appDir, [], { stdout: true, }) + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -720,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/) }) @@ -757,9 +775,10 @@ describe('SCSS Support', () => { let appPort let app let stdout + let code beforeAll(async () => { await remove(join(appDir, '.next')) - ;({ stdout } = await nextBuild(appDir, [], { + ;({ code, stdout } = await nextBuild(appDir, [], { stdout: true, })) appPort = await findPort() @@ -770,6 +789,7 @@ describe('SCSS Support', () => { }) it('should have compiled successfully', () => { + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -791,9 +811,10 @@ describe('SCSS Support', () => { }) it('should compile successfully', async () => { - const { stdout } = await nextBuild(appDir, [], { + const { code, stdout } = await nextBuild(appDir, [], { stdout: true, }) + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) }) @@ -831,9 +852,10 @@ describe('SCSS Support', () => { }) it('should compile successfully', async () => { - const { stdout } = await nextBuild(appDir, [], { + const { code, stdout } = await nextBuild(appDir, [], { stdout: true, }) + expect(code).toBe(0) expect(stdout).toMatch(/Compiled successfully/) })