Skip to content

Commit

Permalink
Fix issue with UUID library in Jest
Browse files Browse the repository at this point in the history
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.<anonymous>":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
```
  • Loading branch information
fluiddot committed Jun 16, 2023
1 parent b7b7ca7 commit f79971e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ module.exports = {
'test/helpers$': '<rootDir>/' + configPath + '/helpers.js',
jetpackConfig:
'<rootDir>/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,
Expand Down

0 comments on commit f79971e

Please sign in to comment.