From f79971e321475897f91d97e5437478d3459cf5ae Mon Sep 17 00:00:00 2001 From: Carlos Garcia Date: Fri, 16 Jun 2023 19:18:37 +0200 Subject: [PATCH] Fix issue with UUID library in Jest This fixes an issue related to the UUID library when running tests. Without this change, we get the following error: ``` /gutenberg-mobile/gutenberg/node_modules/uuid/dist/esm-browser/index.js:1 ({"Object.":function(module,exports,require,__dirname,__filename,jest){export { default as v1 } from './v1.js'; ^^^^^^ SyntaxError: Unexpected token 'export' 3 | */ 4 | import fastDeepEqual from 'fast-deep-equal/es6'; > 5 | import { v4 as uuid } from 'uuid'; | ^ 6 | 7 | /** 8 | * WordPress dependencies ``` --- jest.config.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jest.config.js b/jest.config.js index a49f191afa..9bb212a761 100644 --- a/jest.config.js +++ b/jest.config.js @@ -56,6 +56,9 @@ module.exports = { 'test/helpers$': '/' + configPath + '/helpers.js', jetpackConfig: '/jetpack/tools/js-tools/jest/jest-jetpack-config.js', + // Workaround for Jest not having ESM support yet + // Reference: https://t.ly/9ap_ + uuid: require.resolve( 'uuid' ), }, haste: { defaultPlatform: rnPlatform,