From 8f28c88aa52427090e09d3207009d48049f6a887 Mon Sep 17 00:00:00 2001 From: Chris Midgley Date: Sun, 6 Feb 2022 21:19:16 +0000 Subject: [PATCH] Allow passing nothing as custom jest config. (#32328) If you don't have any config, currently you need to pass `{}`, which is less convenient than being able to pass nothing. --- packages/next/build/jest/jest.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/next/build/jest/jest.ts b/packages/next/build/jest/jest.ts index 92b1a7737b5e7f4..f410836890f8a44 100644 --- a/packages/next/build/jest/jest.ts +++ b/packages/next/build/jest/jest.ts @@ -46,7 +46,7 @@ module.exports = createJestConfig(customJestConfig) */ export default function nextJest(options: { dir?: string } = {}) { // createJestConfig - return (customJestConfig: any) => { + return (customJestConfig?: any) => { // Function that is provided as the module.exports of jest.config.js // Will be called and awaited by Jest return async () => { @@ -68,9 +68,9 @@ export default function nextJest(options: { dir?: string } = {}) { } // Ensure provided async config is supported const resolvedJestConfig = - typeof customJestConfig === 'function' + (typeof customJestConfig === 'function' ? await customJestConfig() - : customJestConfig + : customJestConfig) ?? {} return { ...resolvedJestConfig,