fix(web): load shared test compat setup#1662
Merged
Conversation
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.
Summary
expectglobally so direct@testing-library/jest-domimports work in web testsTooltipWrappermock that could bleed into the realTooltipWrappertests under CI file orderingmock.modulestate cannot leak between filesuseOpenAtCursortest mocks so they no longer require the real module from inside its own mock factoryWhy Tests Were Failing
The core test command itself was passing, but the web unit job imports the shared core test startup from
web.preload.ts. After the backend/core fix, that shared startup callsjest.mockthroughmockBSON(). The web preload did not install the shared compatibility setup first, sojest.mockwas unavailable and the preload stopped before it created DOM globals. That caused the broad cascade of missingdocument,window, and related failures in the web job.After installing the compatibility setup first, the remaining failures came from tests that import
@testing-library/jest-domdirectly. That package expectsexpectto be global, while the web preload only imported and extended Bun’sexpectlocally. The preload now exposes that sameexpectglobally.CI then exposed Bun 1.2.18 ordering issues in tests that register global
mock.modulemocks. A stale AuthModal mock forTooltipWrapperleaked into the realTooltipWrappertests; removing it fixed that leak. Other failures came from interleaved files mocking shared modules likeuseOpenAtCursor, so the existing test dispatcher now executes each web test file in a separate Bun process.Verification
bunx bun@1.2.18 packages/scripts/src/testing/run.ts webbun run test:webbun run test:core./node_modules/.bin/biome check package.json packages/scripts/src/testing/run.ts packages/web/src/__tests__/web.preload.ts packages/web/src/components/AuthModal/AuthModal.test.tsx packages/web/src/common/hooks/useEventDNDActions.test.ts packages/web/src/common/hooks/useEventResizeActions.test.ts packages/web/src/views/Day/hooks/events/useOpenEventContextMenu.test.ts packages/web/src/views/Day/hooks/events/useOpenAgendaEventPreview.test.ts packages/web/src/views/Forms/hooks/useCloseEventForm.test.tsNotes
Instance failed to start within 10000ms), not on the test-compat code path. The backend CI job had already passed after the original backend fix.