From 684c8ff4d0ef2e5d7046195750ecc65d14a108a1 Mon Sep 17 00:00:00 2001 From: Christoph Tavan Date: Mon, 28 Oct 2019 20:24:05 +0100 Subject: [PATCH] Add integration test to cover #7894 --- .../pages/page-1.js | 2 + .../pages/page-2.js | 2 + .../test/index.test.js | 37 +++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 test/integration/build-firebase-only-sequentially/pages/page-1.js create mode 100644 test/integration/build-firebase-only-sequentially/pages/page-2.js create mode 100644 test/integration/build-firebase-only-sequentially/test/index.test.js diff --git a/test/integration/build-firebase-only-sequentially/pages/page-1.js b/test/integration/build-firebase-only-sequentially/pages/page-1.js new file mode 100644 index 0000000000000..dd9c28611eea2 --- /dev/null +++ b/test/integration/build-firebase-only-sequentially/pages/page-1.js @@ -0,0 +1,2 @@ +import 'firebase/firestore' +export default () =>
Firebase
diff --git a/test/integration/build-firebase-only-sequentially/pages/page-2.js b/test/integration/build-firebase-only-sequentially/pages/page-2.js new file mode 100644 index 0000000000000..dd9c28611eea2 --- /dev/null +++ b/test/integration/build-firebase-only-sequentially/pages/page-2.js @@ -0,0 +1,2 @@ +import 'firebase/firestore' +export default () =>
Firebase
diff --git a/test/integration/build-firebase-only-sequentially/test/index.test.js b/test/integration/build-firebase-only-sequentially/test/index.test.js new file mode 100644 index 0000000000000..c6ab580e20385 --- /dev/null +++ b/test/integration/build-firebase-only-sequentially/test/index.test.js @@ -0,0 +1,37 @@ +/* eslint-env jest */ +/* global jasmine */ +import path from 'path' +import fs from 'fs-extra' +import { nextBuild } from 'next-test-utils' + +jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 1 +const appDir = path.join(__dirname, '..') +const nextConfig = path.join(appDir, 'next.config.js') + +describe('Builds with firebase dependency only sequentially', () => { + it('Throws an error when building with firebase dependency in parallel', async () => { + await fs.writeFile( + nextConfig, + `module.exports = { experimental: { cpus: 2 } }` + ) + const results = await nextBuild(appDir, [], { stdout: true, stderr: true }) + expect(results.stdout + results.stderr).toMatch(/Build error occurred/) + expect(results.stdout + results.stderr).toMatch( + /grpc_node\.node\. Module did not self-register\./ + ) + await fs.remove(nextConfig) + }) + + it('Throws no error when building with firebase dependency in sequence', async () => { + await fs.writeFile( + nextConfig, + `module.exports = { experimental: { cpus: 1 } }` + ) + const results = await nextBuild(appDir, [], { stdout: true, stderr: true }) + expect(results.stdout + results.stderr).not.toMatch(/Build error occurred/) + expect(results.stdout + results.stderr).not.toMatch( + /grpc_node\.node\. Module did not self-register\./ + ) + await fs.remove(nextConfig) + }) +})