test(frontend): Migrate from describe/it to flat test() pattern #35305
+1,994
−1,531
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements a comprehensive migration strategy to move away from nested
describe
/it
test patterns to flattest()
functions, following Kent C. Dodds' "avoid nesting when testing" best practices.Changes
1. ESLint Rules Enforcement
jest/consistent-test-it
rule to enforcetest
overit
no-restricted-globals
rule to error ondescribe
andit
usagesuperset-frontend/src/.eslintrc.json
2. Automated Migrations
it
totest
: 194 files updated vianpm run lint-fix
3. Legacy Code Handling
eslint-disable
comments with TODO markers to 243 files containingdescribe
blocksdescribe
blocks with:// eslint-disable-next-line no-restricted-globals -- TODO: Migrate from describe blocks
Migration Statistics
it
→test
migration: 100% complete (194 files)describe
blocks removed: 5 files (simple cases without hooks)describe
blocks with TODOs: 243 files (to be migrated gradually)Files Successfully Flattened
These files had simple
describe
blocks without hooks and were safely migrated:utils/urlUtils.test.ts
explore/controlPanels/Separator.test.ts
components/ErrorMessage/ErrorAlert.test.tsx
components/ModalTitleWithIcon/ModalTitleWithIcon.test.tsx
components/MessageToasts/reducers.test.js
Benefits
describe
/it
(ESLint error)Testing Instructions
Run tests to confirm everything still passes:
npm run test
Try adding a new
describe
block - it should trigger an ESLint error:New tests should use flat structure:
Additional Information
This migration follows React Testing Library and Jest best practices. The flat test structure:
The TODO markers allow us to track and gradually migrate the remaining
describe
blocks without breaking existing tests.🤖 Generated with Claude Code
Co-Authored-By: Claude [email protected]