fix: keep frontend-base out of a consuming app's jest crawl - #302
Merged
Conversation
A checkout in an app's packages/ directory was crawled by jest-haste-map, which registered frontend-base's manual mock of universal-cookie for every one of the app's test suites and collected frontend-base's own suites alongside the app's. That mock is not constructible, so every suite failed to start. The universal-cookie mocks were unreachable inside frontend-base anyway, since both setupTest files register their own factory. The remaining asset mocks move out of __mocks__ so they are no longer registered as manual mocks at all. test-site now runs a jest suite of its own, giving the shipped test config its first coverage. Fixes openedx#287 Co-Authored-By: Claude <noreply@anthropic.com>
arbrandes
enabled auto-merge (rebase)
August 29, 2026 12:49
|
🎉 This PR is included in version 2.0.0-alpha.6 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Description
When
frontend-baseis checked out into a consuming app'spackages/directory, every one of that app's test suites fails to start withTypeError: _universalCookie.default is not a constructor.jest-haste-map crawls the whole app,
packages/included, and registers the two__mocks__/universal-cookie.jsfiles it finds there. A manual mock for a node module is applied automatically, with nojest.mock()call, and that mock body is an arrow function, which cannot be constructed. The same crawl also collectsfrontend-base's own suites and runs them as the app's.Both mocks were already unreachable inside
frontend-base, since eachsetupTest.jsregisters its own factory. They are deleted rather than repaired: a working mock would still silently stub a third-party package in every consuming suite. The remaining asset mocks are onlymoduleNameMappertargets, so they move totestMocks/.createConfig('test')now excludes<rootDir>/packages/, where the migration guide already says gitignored dev bind-mounts live.roots: ['<rootDir>/src']would also work, but it hard-errors for an app without asrc/directory and silently drops any suite outside it -frontend-app-authoringkeeps nine underplugins/. It is documented as an opt-in instead.test-sitegains a jest config and two smoke tests, giving the shipped test config its first coverage.Fixes #287
LLM usage notice
Built with assistance from Claude.