fix: repair broken Jest test suite (16/18 suites failing)#410
Open
shaunpatterson wants to merge 2 commits into
Open
fix: repair broken Jest test suite (16/18 suites failing)#410shaunpatterson wants to merge 2 commits into
shaunpatterson wants to merge 2 commits into
Conversation
Every component test suite has been failing to run. Four independent breakages, all in test infrastructure - no production code changes: - ESM-only packages were never transpiled: the babel config lives in package.json (file-relative, like .babelrc), so it is not applied to files inside node_modules even when transformIgnorePatterns allows them through. Added config/jest/babelTransform.js (explicit presets) and allowed react-leaflet/@react-leaflet through the transform. - Jest 26 cannot resolve node:-prefixed core modules required by newer transitive deps (cheerio -> parse5/undici). Added shim files under config/jest/nodeShims plus a moduleNameMapper rule. - enzyme 3 requires cheerio/lib/utils, which no longer exists in cheerio 1.x final (the lockfile resolves enzyme's ^1.0.0-rc.3 range to 1.1.2). Mapped to its new location (dist/commonjs/utils.js). - jsdom 16 lacks TextEncoder/TextDecoder, web streams, Blob and MessageChannel globals that undici needs. Added a Jest-only setupFiles polyfill (kept out of config/polyfills.js, which is also a webpack entry). Also split e2e tests out of the default run: they need puppeteer and a live Dgraph cluster, so 14 suites always failed in a plain checkout. 'npm test' now runs unit tests only; 'npm run test:e2e' runs the rest. Result: npm test goes from 16/18 suites failing to 4/4 passing (13 tests). Production build verified unaffected. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jun 12, 2026
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
npm testcurrently fails 16 of 18 suites in a clean checkout of main. None of the failures are real test regressions — they are all test-infrastructure breakages:package.json(file-relative, like.babelrc), so it is not applied to files insidenode_moduleseven iftransformIgnorePatternslets them through.react-leaflet4 is ESM-only →SyntaxError: Unexpected token 'export'in every suite that transitively imports the app.node:-prefixed core modules required by newer transitive deps (cheerio → parse5/undici).cheerio/lib/utils, which no longer exists in cheerio 1.x final (the lockfile resolves enzyme's^1.0.0-rc.3range to 1.1.2).TextEncoder/TextDecoder, web streams,BlobandMessageChannelglobals that undici needs at import time.npm testbut require puppeteer (optional dep) plus a live Dgraph cluster atlocalhost:8080, so 14 suites always fail locally and in CI-less environments.Fix
config/jest/babelTransform.js: dedicated babel-jest transformer with explicit presets, so allowed-through node_modules files actually get compiled;transformIgnorePatternsnow whitelistsreact-leaflet/@react-leaflet.config/jest/nodeShims/*: one-line shims + amoduleNameMapperrule mappingnode:<mod>→ the bare core module.moduleNameMapperentry pointingcheerio/lib/utilsat its new location (dist/commonjs/utils.js); enzyme is test-only so a Jest mapping is sufficient.config/jest/testPolyfills.jsadded tosetupFiles(kept separate fromconfig/polyfills.js, which is also a webpack entry and must not require node core modules).npm testruns unit tests,npm run test:e2erunssrc/e2etests(unchanged behavior otherwise).Result
npm testNo production code or dependency changes;
npm run buildverified unaffected.🤖 Generated with Claude Code