From 701b1efd429964d68e14aefa27055bf2af24f66e Mon Sep 17 00:00:00 2001 From: Heath Chiavettone Date: Fri, 22 Aug 2025 13:10:32 -0700 Subject: [PATCH 1/2] Fix 4726 by removing nanoid in favor of lodash.uniqueId Fixed #4726 by removing nanoid in favor of lodash.uniqueId - Uninstalled `nanoid` from `@rjsf/utils` and `@rjsf/semantic-ui`, switching to use `uniqueId` from lodash in `utils`'s `getTestId()` and `semantic-ui`'s `FieldErrorTemplate` - Updated all of the `jest.config.js` file to remove `nanoid` - Updated `CHANGELOG.md` accordingly # Conflicts: # CHANGELOG.md --- CHANGELOG.md | 12 ++ package-lock.json | 147 ++++++------------ packages/antd/jest.config.json | 2 +- packages/chakra-ui/jest.config.json | 2 +- packages/core/jest.config.json | 2 +- packages/core/package.json | 1 - packages/daisyui/jest.config.json | 2 +- packages/daisyui/test/helpers/createMocks.ts | 4 +- packages/fluentui-rc/jest.config.json | 2 +- packages/mui/jest.config.json | 2 +- packages/playground/jest.config.json | 2 +- packages/primereact/jest.config.json | 2 +- packages/react-bootstrap/jest.config.json | 2 +- packages/semantic-ui/jest.config.json | 2 +- packages/semantic-ui/package.json | 1 - .../FieldErrorTemplate/FieldErrorTemplate.tsx | 4 +- packages/shadcn/jest.config.json | 2 +- packages/utils/jest.config.json | 2 +- packages/utils/package.json | 1 - packages/utils/src/getTestIds.ts | 4 +- packages/utils/test/getTestIds.test.ts | 21 +-- packages/validator-ajv8/jest.config.json | 2 +- 22 files changed, 93 insertions(+), 128 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6aadd8c793..62a7027bbb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,11 +17,23 @@ should change the heading of the (upcoming) version to include a major version b --> # 6.0.0-beta.15 +## @rjsf/semantic-ui + +- Updated `ArrayField` to stop using `nanoid` and instead use `lodash/uniqueId` to fix [#4762](https://github.com/rjsf-team/react-jsonschema-form/issues/4726) + ## @rjsf/shadcn - Update `README.md` with picture of the theme! - Allow passing `className` props to `AddButton`, `BaseInputTemplate`, `CheckboxWidget`, `CheckboxesWidget`, `RadioWidget`, `SelectWidget`, `SubmitButton`, `TextareaWidget` for extra Tailwind CSS customization through `ui:className` +## @rjsf/utils + +- Updated `getTestIds` to stop using `nanoid` and instead use `lodash/uniqueId` to fix [#4762](https://github.com/rjsf-team/react-jsonschema-form/issues/4726) + +## Dev / docs / playground + +- Removed `nanoid` from the build system and `jest.config.js` files + # 6.0.0-beta.14 ## @rjsf/core diff --git a/package-lock.json b/package-lock.json index e1f612abd3..a4200e7592 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5714,9 +5714,9 @@ } }, "node_modules/@floating-ui/dom": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.7.3.tgz", - "integrity": "sha512-uZA413QEpNuhtb3/iIKoYMSK07keHPYeXF02Zhd6e213j+d1NamLix/mCLxBUDW/Gx52sPH2m+chlUsyaBs/Ag==", + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.7.4.tgz", + "integrity": "sha512-OOchDgh4F2CchOX94cRVqhvy7b3AFb+/rQXyswmzmGakRfkMgoWVjfnLWkRirfLEfuD4ysVW16eXzwt3jHIzKA==", "license": "MIT", "dependencies": { "@floating-ui/core": "^1.7.3", @@ -7652,9 +7652,9 @@ } }, "node_modules/@isaacs/cliui/node_modules/ansi-regex": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", - "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.0.tgz", + "integrity": "sha512-TKY5pyBkHyADOPYlRT9Lx6F544mPl0vS5Ew7BJ45hA08Q+t3GjbueLliBWN3sMICk6+y7HdyxSzC4bWS8baBdg==", "dev": true, "license": "MIT", "engines": { @@ -11070,9 +11070,9 @@ "license": "BSD-3-Clause" }, "node_modules/@sinclair/typebox": { - "version": "0.34.38", - "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.34.38.tgz", - "integrity": "sha512-HpkxMmc2XmZKhvaKIZZThlHmx1L0I/V1hWK1NubtlFnr6ZqdiOpV72TKudZUNQjZNsyDBay72qFEhEvb+bcwcA==", + "version": "0.34.40", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.34.40.tgz", + "integrity": "sha512-gwBNIP8ZAYev/ORDWW0QvxdwPXwxBtLsdsJgSc7eDIRt8ubP+rxUBzPsrwnu16fgEF8Bx4lh/+mvQvJzcTM6Kw==", "dev": true, "license": "MIT" }, @@ -12497,18 +12497,6 @@ } }, "node_modules/@types/express-serve-static-core": { - "version": "5.0.7", - "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-5.0.7.tgz", - "integrity": "sha512-R+33OsgWw7rOhD1emjU7dzCDHucJrgJXMA5PYCzJxVil0dsyx5iBEPHqpPfiKNJQb7lZ1vxwoLR4Z87bBUpeGQ==", - "license": "MIT", - "dependencies": { - "@types/node": "*", - "@types/qs": "*", - "@types/range-parser": "*", - "@types/send": "*" - } - }, - "node_modules/@types/express/node_modules/@types/express-serve-static-core": { "version": "4.19.6", "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.19.6.tgz", "integrity": "sha512-N4LZ2xG7DatVqhCZzOGb1Yi5lMbXSZcmdLDe9EzSndPV2HpWYWzRbaerl2n27irrm94EPpprqa8KpskPT085+A==", @@ -12680,9 +12668,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "22.17.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.17.1.tgz", - "integrity": "sha512-y3tBaz+rjspDTylNjAX37jEC3TETEFGNJL6uQDxwF9/8GLLIjW1rvVHlynyuUKMnMr1Roq8jOv3vkopBjC4/VA==", + "version": "22.17.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.17.2.tgz", + "integrity": "sha512-gL6z5N9Jm9mhY+U2KXZpteb+09zyffliRkZyZOHODGATyC5B1Jt/7TzuuiLkFsSUMLbS1OLmlj/E+/3KF4Q/4w==", "license": "MIT", "dependencies": { "undici-types": "~6.21.0" @@ -14929,9 +14917,9 @@ } }, "node_modules/antd": { - "version": "5.27.0", - "resolved": "https://registry.npmjs.org/antd/-/antd-5.27.0.tgz", - "integrity": "sha512-o54dmpooLOc08RSGCkeEQBYAGPxUSmnhmYJKCNTHH46vzjOVxdteu+wPTRVkRbAkDTbs2VcNr5VL7Lu67rPIiA==", + "version": "5.27.1", + "resolved": "https://registry.npmjs.org/antd/-/antd-5.27.1.tgz", + "integrity": "sha512-jGMSdBN7hAMvPV27B4RhzZfL6n6yu8yDbo7oXrlJasaOqB7bSDPcjdEy1kXy3JPsny/Qazb1ykzRI4EfcByAPQ==", "license": "MIT", "dependencies": { "@ant-design/colors": "^7.2.1", @@ -15948,9 +15936,9 @@ } }, "node_modules/boxen/node_modules/ansi-regex": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", - "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.0.tgz", + "integrity": "sha512-TKY5pyBkHyADOPYlRT9Lx6F544mPl0vS5Ew7BJ45hA08Q+t3GjbueLliBWN3sMICk6+y7HdyxSzC4bWS8baBdg==", "license": "MIT", "engines": { "node": ">=12" @@ -24200,9 +24188,9 @@ } }, "node_modules/jest-watch-typeahead/node_modules/ansi-regex": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", - "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.0.tgz", + "integrity": "sha512-TKY5pyBkHyADOPYlRT9Lx6F544mPl0vS5Ew7BJ45hA08Q+t3GjbueLliBWN3sMICk6+y7HdyxSzC4bWS8baBdg==", "dev": true, "license": "MIT", "engines": { @@ -24213,9 +24201,9 @@ } }, "node_modules/jest-watch-typeahead/node_modules/chalk": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.5.0.tgz", - "integrity": "sha512-1tm8DTaJhPBG3bIkVeZt1iZM9GfSX2lzOeDVZH9R9ffRHpmHvxZ/QhgQH/aDTkswQVt+YHdXAdS/In/30OjCbg==", + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.6.0.tgz", + "integrity": "sha512-46QrSQFyVSEyYAgQ22hQ+zDa60YHA4fBstHmtSApj1Y5vKtG27fWowW03jCk5KcbXEWPZUIR894aARCA/G1kfQ==", "dev": true, "license": "MIT", "engines": { @@ -24420,9 +24408,9 @@ } }, "node_modules/jsesc": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz", - "integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.0.2.tgz", + "integrity": "sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g==", "license": "MIT", "bin": { "jsesc": "bin/jsesc" @@ -24975,9 +24963,9 @@ } }, "node_modules/lint-staged/node_modules/chalk": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.5.0.tgz", - "integrity": "sha512-1tm8DTaJhPBG3bIkVeZt1iZM9GfSX2lzOeDVZH9R9ffRHpmHvxZ/QhgQH/aDTkswQVt+YHdXAdS/In/30OjCbg==", + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.6.0.tgz", + "integrity": "sha512-46QrSQFyVSEyYAgQ22hQ+zDa60YHA4fBstHmtSApj1Y5vKtG27fWowW03jCk5KcbXEWPZUIR894aARCA/G1kfQ==", "dev": true, "license": "MIT", "engines": { @@ -25159,9 +25147,9 @@ } }, "node_modules/log-update/node_modules/ansi-regex": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", - "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.0.tgz", + "integrity": "sha512-TKY5pyBkHyADOPYlRT9Lx6F544mPl0vS5Ew7BJ45hA08Q+t3GjbueLliBWN3sMICk6+y7HdyxSzC4bWS8baBdg==", "dev": true, "license": "MIT", "engines": { @@ -28350,24 +28338,6 @@ "url": "https://github.com/sindresorhus/nano-spawn?sponsor=1" } }, - "node_modules/nanoid": { - "version": "5.1.5", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-5.1.5.tgz", - "integrity": "sha512-Ir/+ZpE9fDsNH0hQ3C68uyThDXzYcim2EqcZ8zn8Chtt1iylPT9xXJB0kPCnqzgcEGikO9RxSrh63MsmVCU7Fw==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "license": "MIT", - "bin": { - "nanoid": "bin/nanoid.js" - }, - "engines": { - "node": "^18 || >=20" - } - }, "node_modules/napi-postinstall": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/napi-postinstall/-/napi-postinstall-0.3.3.tgz", @@ -31350,9 +31320,9 @@ "license": "MIT" }, "node_modules/primereact": { - "version": "10.9.6", - "resolved": "https://registry.npmjs.org/primereact/-/primereact-10.9.6.tgz", - "integrity": "sha512-0Jjz/KzfUURSHaPTXJwjL2Dc7CDPnbO17MivyJz7T5smGAMLY5d+IqpQhV61R22G/rDmhMh3+32LCNva2M8fRw==", + "version": "10.9.7", + "resolved": "https://registry.npmjs.org/primereact/-/primereact-10.9.7.tgz", + "integrity": "sha512-Ap/lg9GGaS8Pq7IIlzguuG3qlaU6PYF6E0cCRo0rnWauRw/SQGvfreSVIIxqEhtR6xqlf7OV759lyvVOvBzmsQ==", "dev": true, "license": "MIT", "dependencies": { @@ -33162,18 +33132,6 @@ "regjsparser": "bin/parser" } }, - "node_modules/regjsparser/node_modules/jsesc": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.0.2.tgz", - "integrity": "sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g==", - "license": "MIT", - "bin": { - "jsesc": "bin/jsesc" - }, - "engines": { - "node": ">=6" - } - }, "node_modules/rehype-raw": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/rehype-raw/-/rehype-raw-7.0.0.tgz", @@ -34946,9 +34904,9 @@ } }, "node_modules/string-width/node_modules/ansi-regex": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", - "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.0.tgz", + "integrity": "sha512-TKY5pyBkHyADOPYlRT9Lx6F544mPl0vS5Ew7BJ45hA08Q+t3GjbueLliBWN3sMICk6+y7HdyxSzC4bWS8baBdg==", "dev": true, "license": "MIT", "engines": { @@ -36779,9 +36737,9 @@ } }, "node_modules/update-notifier/node_modules/ansi-regex": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", - "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.0.tgz", + "integrity": "sha512-TKY5pyBkHyADOPYlRT9Lx6F544mPl0vS5Ew7BJ45hA08Q+t3GjbueLliBWN3sMICk6+y7HdyxSzC4bWS8baBdg==", "license": "MIT", "engines": { "node": ">=12" @@ -36837,9 +36795,9 @@ } }, "node_modules/update-notifier/node_modules/chalk": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.5.0.tgz", - "integrity": "sha512-1tm8DTaJhPBG3bIkVeZt1iZM9GfSX2lzOeDVZH9R9ffRHpmHvxZ/QhgQH/aDTkswQVt+YHdXAdS/In/30OjCbg==", + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.6.0.tgz", + "integrity": "sha512-46QrSQFyVSEyYAgQ22hQ+zDa60YHA4fBstHmtSApj1Y5vKtG27fWowW03jCk5KcbXEWPZUIR894aARCA/G1kfQ==", "license": "MIT", "engines": { "node": "^12.17.0 || ^14.13 || >=16.0.0" @@ -38015,9 +37973,9 @@ } }, "node_modules/widest-line/node_modules/ansi-regex": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", - "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.0.tgz", + "integrity": "sha512-TKY5pyBkHyADOPYlRT9Lx6F544mPl0vS5Ew7BJ45hA08Q+t3GjbueLliBWN3sMICk6+y7HdyxSzC4bWS8baBdg==", "license": "MIT", "engines": { "node": ">=12" @@ -38158,9 +38116,9 @@ } }, "node_modules/wrap-ansi/node_modules/ansi-regex": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", - "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.0.tgz", + "integrity": "sha512-TKY5pyBkHyADOPYlRT9Lx6F544mPl0vS5Ew7BJ45hA08Q+t3GjbueLliBWN3sMICk6+y7HdyxSzC4bWS8baBdg==", "dev": true, "license": "MIT", "engines": { @@ -38540,7 +38498,6 @@ "lodash": "^4.17.21", "lodash-es": "^4.17.21", "markdown-to-jsx": "^7.7.13", - "nanoid": "^5.1.5", "prop-types": "^15.8.1" }, "devDependencies": { @@ -39100,7 +39057,6 @@ "@rjsf/validator-ajv8": "^6.0.0-beta.14", "atob": "^2.1.2", "eslint": "^8.57.1", - "nanoid": "^5.1.5", "semantic-ui-react": "^2.1.5" }, "engines": { @@ -39187,7 +39143,6 @@ "jsonpointer": "^5.0.1", "lodash": "^4.17.21", "lodash-es": "^4.17.21", - "nanoid": "^5.1.5", "react-is": "^18.3.1" }, "devDependencies": { diff --git a/packages/antd/jest.config.json b/packages/antd/jest.config.json index c92da2b002..7eb9155251 100644 --- a/packages/antd/jest.config.json +++ b/packages/antd/jest.config.json @@ -7,5 +7,5 @@ "moduleNameMapper": { "\\.(css|less)$": "/__mocks__/styleMock.js" }, - "transformIgnorePatterns": ["/node_modules/(?!nanoid|deep-freeze-es6)"] + "transformIgnorePatterns": ["/node_modules/(?!deep-freeze-es6)"] } diff --git a/packages/chakra-ui/jest.config.json b/packages/chakra-ui/jest.config.json index 72a7f38d65..e4f5c06cdc 100644 --- a/packages/chakra-ui/jest.config.json +++ b/packages/chakra-ui/jest.config.json @@ -5,5 +5,5 @@ "browsers": ["chrome", "firefox", "safari"] }, "setupFilesAfterEnv": ["./test/setup-jest-env.js"], - "transformIgnorePatterns": ["/node_modules/(?!nanoid|deep-freeze-es6)"] + "transformIgnorePatterns": ["/node_modules/(?!deep-freeze-es6)"] } diff --git a/packages/core/jest.config.json b/packages/core/jest.config.json index a4227b7482..a826dd376e 100644 --- a/packages/core/jest.config.json +++ b/packages/core/jest.config.json @@ -3,5 +3,5 @@ "testEnvironment": "jsdom", "setupFilesAfterEnv": ["./test/setup-jest-env.js"], "testMatch": ["**/test/**/*.test.[jt]s?(x)"], - "transformIgnorePatterns": ["/node_modules/(?!nanoid|deep-freeze-es6)"] + "transformIgnorePatterns": ["/node_modules/(?!deep-freeze-es6)"] } diff --git a/packages/core/package.json b/packages/core/package.json index 4dde319178..62afb0bf0d 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -73,7 +73,6 @@ "lodash": "^4.17.21", "lodash-es": "^4.17.21", "markdown-to-jsx": "^7.7.13", - "nanoid": "^5.1.5", "prop-types": "^15.8.1" }, "devDependencies": { diff --git a/packages/daisyui/jest.config.json b/packages/daisyui/jest.config.json index 6e803bd58b..aad0bf0c52 100644 --- a/packages/daisyui/jest.config.json +++ b/packages/daisyui/jest.config.json @@ -6,7 +6,7 @@ }, "coveragePathIgnorePatterns": ["/node_modules/", "/test/"], "transformIgnorePatterns": [ - "/node_modules/(?!(@rjsf|@epicfaace|nanoid|@fortawesome|@coreui|yup|react-day-picker|dayjs|deep-freeze-es6)/)" + "/node_modules/(?!(@rjsf|@epicfaace|@fortawesome|@coreui|yup|react-day-picker|dayjs|deep-freeze-es6)/)" ], "moduleNameMapper": { "\\.(css|less|scss|sass)$": "/test/fileMock.js" diff --git a/packages/daisyui/test/helpers/createMocks.ts b/packages/daisyui/test/helpers/createMocks.ts index acf87808fe..4ee0ed732b 100644 --- a/packages/daisyui/test/helpers/createMocks.ts +++ b/packages/daisyui/test/helpers/createMocks.ts @@ -6,8 +6,8 @@ import Templates from '../../src/templates/Templates'; import generateWidgets from '../../src/widgets/Widgets'; // Mock any problematic dependencies -// This helps when a dependency like nanoid uses ESM -jest.mock('nanoid', () => ({ +// This helps when a dependency like uniqueId uses ESM +jest.mock('lodash/uniqueId', () => ({ nanoid: () => 'test-id-12345', })); diff --git a/packages/fluentui-rc/jest.config.json b/packages/fluentui-rc/jest.config.json index d4c5628abd..1972bebc5c 100644 --- a/packages/fluentui-rc/jest.config.json +++ b/packages/fluentui-rc/jest.config.json @@ -4,5 +4,5 @@ "testEnvironmentOptions": { "browsers": ["chrome", "firefox", "safari"] }, - "transformIgnorePatterns": ["/node_modules/(?!nanoid|deep-freeze-es6)"] + "transformIgnorePatterns": ["/node_modules/(?!deep-freeze-es6)"] } diff --git a/packages/mui/jest.config.json b/packages/mui/jest.config.json index d4c5628abd..1972bebc5c 100644 --- a/packages/mui/jest.config.json +++ b/packages/mui/jest.config.json @@ -4,5 +4,5 @@ "testEnvironmentOptions": { "browsers": ["chrome", "firefox", "safari"] }, - "transformIgnorePatterns": ["/node_modules/(?!nanoid|deep-freeze-es6)"] + "transformIgnorePatterns": ["/node_modules/(?!deep-freeze-es6)"] } diff --git a/packages/playground/jest.config.json b/packages/playground/jest.config.json index 927cca653d..147972260c 100644 --- a/packages/playground/jest.config.json +++ b/packages/playground/jest.config.json @@ -2,5 +2,5 @@ "verbose": true, "testEnvironment": "jsdom", "testMatch": ["**/test/**/*.test.[jt]s?(x)"], - "transformIgnorePatterns": ["/node_modules/(?!nanoid|deep-freeze-es6)"] + "transformIgnorePatterns": ["/node_modules/(?!deep-freeze-es6)"] } diff --git a/packages/primereact/jest.config.json b/packages/primereact/jest.config.json index ec94a1f9b8..335b8ad9fb 100644 --- a/packages/primereact/jest.config.json +++ b/packages/primereact/jest.config.json @@ -3,7 +3,7 @@ "transform": { "^.+\\.(ts|tsx|js|jsx)$": ["babel-jest", { "configFile": "./babel.config.json" }] }, - "transformIgnorePatterns": ["/node_modules/(?!nanoid|deep-freeze-es6)"], + "transformIgnorePatterns": ["/node_modules/(?!deep-freeze-es6)"], "moduleNameMapper": { "^@/(.*)$": "/src/$1" }, diff --git a/packages/react-bootstrap/jest.config.json b/packages/react-bootstrap/jest.config.json index 886fae028d..0354ad732a 100644 --- a/packages/react-bootstrap/jest.config.json +++ b/packages/react-bootstrap/jest.config.json @@ -1,3 +1,3 @@ { - "transformIgnorePatterns": ["/node_modules/(?!nanoid|deep-freeze-es6)"] + "transformIgnorePatterns": ["/node_modules/(?!deep-freeze-es6)"] } diff --git a/packages/semantic-ui/jest.config.json b/packages/semantic-ui/jest.config.json index 5a56b2179c..4e5af8b437 100644 --- a/packages/semantic-ui/jest.config.json +++ b/packages/semantic-ui/jest.config.json @@ -1,5 +1,5 @@ { "verbose": true, "testEnvironment": "jsdom", - "transformIgnorePatterns": ["/node_modules/(?!nanoid|deep-freeze-es6)"] + "transformIgnorePatterns": ["/node_modules/(?!deep-freeze-es6)"] } diff --git a/packages/semantic-ui/package.json b/packages/semantic-ui/package.json index 05b84d8064..fed5065bd3 100644 --- a/packages/semantic-ui/package.json +++ b/packages/semantic-ui/package.json @@ -73,7 +73,6 @@ "@rjsf/validator-ajv8": "^6.0.0-beta.14", "atob": "^2.1.2", "eslint": "^8.57.1", - "nanoid": "^5.1.5", "semantic-ui-react": "^2.1.5" }, "publishConfig": { diff --git a/packages/semantic-ui/src/FieldErrorTemplate/FieldErrorTemplate.tsx b/packages/semantic-ui/src/FieldErrorTemplate/FieldErrorTemplate.tsx index 6c15e02d37..a8c12f491a 100644 --- a/packages/semantic-ui/src/FieldErrorTemplate/FieldErrorTemplate.tsx +++ b/packages/semantic-ui/src/FieldErrorTemplate/FieldErrorTemplate.tsx @@ -1,5 +1,5 @@ import { errorId, FieldErrorProps, FormContextType, RJSFSchema, StrictRJSFSchema } from '@rjsf/utils'; -import { nanoid } from 'nanoid'; +import uniqueId from 'lodash/uniqueId'; import { Label, List } from 'semantic-ui-react'; import { getSemanticErrorProps } from '../util'; @@ -33,7 +33,7 @@ export default function FieldErrorTemplate< diff --git a/packages/shadcn/jest.config.json b/packages/shadcn/jest.config.json index 2b56438ab8..20642d83e9 100644 --- a/packages/shadcn/jest.config.json +++ b/packages/shadcn/jest.config.json @@ -3,7 +3,7 @@ "transform": { "^.+\\.(ts|tsx|js|jsx)$": ["babel-jest", { "configFile": "./babel.config.json" }] }, - "transformIgnorePatterns": ["/node_modules/(?!nanoid|deep-freeze-es6)"], + "transformIgnorePatterns": ["/node_modules/(?!deep-freeze-es6)"], "moduleNameMapper": { "^@/(.*)$": "/src/$1" } diff --git a/packages/utils/jest.config.json b/packages/utils/jest.config.json index 53e5f28ff4..0bd26445aa 100644 --- a/packages/utils/jest.config.json +++ b/packages/utils/jest.config.json @@ -5,7 +5,7 @@ "browsers": ["chrome", "firefox", "safari"] }, "testMatch": ["**/test/**/*.test.ts?(x)"], - "transformIgnorePatterns": ["/node_modules/(?!nanoid|deep-freeze-es6)"], + "transformIgnorePatterns": ["/node_modules/(?!deep-freeze-es6)"], "coverageDirectory": "/coverage/", "collectCoverage": true, "coveragePathIgnorePatterns": ["/node_modules/", "/test"], diff --git a/packages/utils/package.json b/packages/utils/package.json index 774b9db2c8..2b7c2fde70 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -70,7 +70,6 @@ "jsonpointer": "^5.0.1", "lodash": "^4.17.21", "lodash-es": "^4.17.21", - "nanoid": "^5.1.5", "react-is": "^18.3.1" }, "devDependencies": { diff --git a/packages/utils/src/getTestIds.ts b/packages/utils/src/getTestIds.ts index 6021512252..a1e456efdc 100644 --- a/packages/utils/src/getTestIds.ts +++ b/packages/utils/src/getTestIds.ts @@ -1,5 +1,5 @@ -import { nanoid } from 'nanoid'; import get from 'lodash/get'; +import uniqueId from 'lodash/uniqueId'; import { TestIdShape } from './types'; @@ -31,7 +31,7 @@ export default function getTestIds(): TestIdShape { { get(_obj, prop) { if (!ids.has(prop)) { - ids.set(prop, nanoid()); + ids.set(prop, uniqueId('test-id-')); } return ids.get(prop); }, diff --git a/packages/utils/test/getTestIds.test.ts b/packages/utils/test/getTestIds.test.ts index 27900436b6..9a8725e94f 100644 --- a/packages/utils/test/getTestIds.test.ts +++ b/packages/utils/test/getTestIds.test.ts @@ -1,12 +1,13 @@ import { TestIdShape, getTestIds } from '../src'; const TEST_UUID_BASE = 'test-uuid-'; -jest.mock('nanoid'); -const nanoidMock = require('nanoid'); +jest.mock('lodash/uniqueId'); +const uniqueIdMock = require('lodash/uniqueId'); +const uniqueId = jest.requireActual('lodash/uniqueId'); -const nanoid = jest.requireActual('nanoid').nanoid; +uniqueIdMock.mockImplementation(() => TEST_UUID_BASE + uniqueId()); -nanoidMock.nanoid.mockImplementation(() => TEST_UUID_BASE + nanoid()); +console.log(uniqueIdMock, uniqueId); describe('getTestIds', () => { describe('process.env.NODE_ENV === "test"', () => { @@ -16,32 +17,32 @@ describe('getTestIds', () => { testIds = getTestIds(); }); afterAll(() => { - nanoidMock.nanoid.mockClear(); + uniqueIdMock.mockClear(); }); it('does not return an empty object', () => { // it returns a Proxy object but since there isn't an easy way to test for it // the following tests will check for the Proxy functionality expect(testIds).not.toEqual({}); - nanoidMock.nanoid.mockClear(); // resetting the call count since the Proxy calls it during the initialization process + uniqueIdMock.mockClear(); // resetting the call count since the Proxy calls it during the initialization process }); it('returns a generated test id when getting a property value', () => { fooTestId = testIds.foo; expect(fooTestId).toEqual(expect.stringContaining(TEST_UUID_BASE)); }); it('called uuid once', () => { - expect(nanoidMock.nanoid).toHaveBeenCalledTimes(1); + expect(uniqueIdMock).toHaveBeenCalledTimes(1); }); it('returns the same id when getting the same property value', () => { expect(testIds.foo).toEqual(fooTestId); }); it('did not call uuid again', () => { - expect(nanoidMock.nanoid).toHaveBeenCalledTimes(1); + expect(uniqueIdMock).toHaveBeenCalledTimes(1); }); it('returns a different id when getting a different property value', () => { expect(testIds.bar).not.toEqual(fooTestId); }); it('called uuid again', () => { - expect(nanoidMock.nanoid).toHaveBeenCalledTimes(2); + expect(uniqueIdMock).toHaveBeenCalledTimes(2); }); }); describe('process.env.NODE_ENV !== "test"', () => { @@ -62,7 +63,7 @@ describe('getTestIds', () => { expect(testIds.foo).toBeUndefined(); }); it('did not call uuid', () => { - expect(nanoidMock.nanoid).not.toHaveBeenCalled(); + expect(uniqueIdMock).not.toHaveBeenCalled(); }); }); }); diff --git a/packages/validator-ajv8/jest.config.json b/packages/validator-ajv8/jest.config.json index 53e5f28ff4..0bd26445aa 100644 --- a/packages/validator-ajv8/jest.config.json +++ b/packages/validator-ajv8/jest.config.json @@ -5,7 +5,7 @@ "browsers": ["chrome", "firefox", "safari"] }, "testMatch": ["**/test/**/*.test.ts?(x)"], - "transformIgnorePatterns": ["/node_modules/(?!nanoid|deep-freeze-es6)"], + "transformIgnorePatterns": ["/node_modules/(?!deep-freeze-es6)"], "coverageDirectory": "/coverage/", "collectCoverage": true, "coveragePathIgnorePatterns": ["/node_modules/", "/test"], From c190d8b2ce988b55f0369feaaffe89685f91990b Mon Sep 17 00:00:00 2001 From: Heath Chiavettone Date: Fri, 22 Aug 2025 13:47:07 -0700 Subject: [PATCH 2/2] - Fixed snapshots for `antd` and remove mocking of `nanoid` for `daisyui` --- .../test/__snapshots__/Array.test.tsx.snap | 870 +++++------ .../test/__snapshots__/Form.test.tsx.snap | 630 ++++---- .../test/__snapshots__/GridSnap.test.tsx.snap | 1372 ++++++++--------- .../test/__snapshots__/Object.test.tsx.snap | 700 ++++----- packages/daisyui/test/helpers/createMocks.ts | 6 - packages/daisyui/test/setup.js | 8 - packages/mantine/jest.config.json | 2 +- 7 files changed, 1787 insertions(+), 1801 deletions(-) diff --git a/packages/antd/test/__snapshots__/Array.test.tsx.snap b/packages/antd/test/__snapshots__/Array.test.tsx.snap index dcc1a04d31..8bb212bccb 100644 --- a/packages/antd/test/__snapshots__/Array.test.tsx.snap +++ b/packages/antd/test/__snapshots__/Array.test.tsx.snap @@ -10,10 +10,10 @@ exports[`array fields array 1`] = ` className="rjsf-field rjsf-field-array" >