This repository has been archived by the owner on Dec 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: replace deprecated shortid with nanoid
Shortid has been deprecated and they recommend nanoid [^1] While upgrading, I tried running the ContextMenu.test.tsx tests without mocking nanoid, but kept getting an error: ``` FAIL src/components/menus/ContextMenu/ContextMenu.test.tsx ● Test suite failed to run Jest encountered an unexpected token Jest failed to parse a file.. ... Details: /Users/ben.turner/src/local/local-components/node_modules/nanoid/index.browser.js:1 ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){export { urlAlphabet } from './url-alphabet/index.js' ^^^^^^ SyntaxError: Unexpected token 'export' 1 | import * as React from 'react'; 2 | import classnames from 'classnames'; > 3 | import { nanoid } from 'nanoid'; | ^ 4 | import { useEffect, useRef, useState } from 'react'; 5 | import styles from './ContextMenu.scss'; 6 | import { FunctionGeneric } from '../../../common/structures/Generics'; at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1796:14) at Object.<anonymous> (src/components/menus/ContextMenu/ContextMenu.tsx:3:1) ``` Nanoid uses ESM for newer versions, which has some issues with running in Jest and the `jsdom` environment. [^2] There were a few things in the comments for that thread that might have worked, but since I was only changing one implementation which didn't really need to test a fully random thing, I opted to just mock nanoid and be done with it. [^1]: https://www.npmjs.com/package/shortid [^2]: ai/nanoid#395
- Loading branch information
Showing
4 changed files
with
12 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters