Commit 28955b2
test: migrate backend and scripts to bun test runner (#2184)
* test: migrate backend and scripts to bun test runner
Retire Jest for the backend and scripts suites in favor of Bun's runner,
driven by a per-file-process launcher over one shared in-memory MongoDB
replica set. Restores Jest-like per-file isolation without per-file startup.
- 3-run medians: backend 43.5s -> 11s (-74%), scripts 52.4s -> 14.7s (-72%).
- Remove jest, @shelf/jest-mongodb, jest-environment-node, @babel/*, and their
config; add mongodb-memory-server. @types/jest kept (type annotations only).
- Retire the six permanently-completed 2025 migration integration suites; add a
fast discovery/ordering guard and a migration baseline README. All migration
implementations and transforms are retained (still used by provisioning/web).
- Mongo test lifecycle: no production backoff under test env, one shared server,
cleanupTestDb no longer disconnects.
- Bun compat fixes: bun:test imports (never jest), requireActual snapshot to
stop mutate-after-mock recursion, lazy mockRejectedValue, stable-per-name
winston mock, mutable compassTestState, .resolves.toBeUndefined().
- Test tiers (fast/db/migrations, auto-classified) and CI mongod binary cache.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* refactor(scripts): tighten migration-discovery guard and runner teardown
- Drop a tautological assertion in migration-discovery.test.ts that compared
a lexicographic sort to itself (always true); keep the meaningful
timestamp-prefix and name-uniqueness checks that actually guard Umzug's order.
- Wrap the launcher's run in try/finally so the in-memory mongod is always
stopped even if a worker throws.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(scripts): declare @sinonjs/fake-timers for the bun compat shim
The jest->bun compat shim requires @sinonjs/fake-timers, previously satisfied
transitively via jest. Removing jest orphaned it, so a frozen-lockfile install
in CI could no longer resolve it and every unit job that loads the shim (core,
web, backend, scripts) failed. Declare it explicitly.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* fix(backend): import lifecycle hooks in preload helpers from bun:test
backend.test.start and mock.setup registered global beforeEach/afterAll via
Bun's injected test globals. From a preloaded (dynamically imported) module that
injection is racy -- one CI run intermittently failed with "afterEach is not
defined" while the same commit passed elsewhere and always passed locally.
Import the hooks explicitly so registration never depends on injection timing.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* test(backend): apply bun test conversions to merged event.service tests
Main's cross-calendar-move suite (#2183) landed after this branch forked. Apply
the same bun:test conversions to it: import afterEach explicitly (Bun disables
injected globals once a file imports from bun:test) and make the rejected mock
lazy so Bun doesn't flag an eager unhandled rejection.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>1 parent 67d94c8 commit 28955b2
114 files changed
Lines changed: 861 additions & 2177 deletions
File tree
- .github/workflows
- docs/development
- packages
- backend
- src
- __tests__
- bench
- helpers
- mocks.gcal/factories
- auth
- controllers
- services
- compass
- google
- clients
- util
- calendar
- controllers
- services
- common
- constants
- errors/handlers
- guards
- middleware
- services
- gcal
- util
- config
- events/controllers
- event
- classes
- controllers
- services
- recur/util
- health/controllers
- servers/sse
- sync
- controllers
- services
- calendarlist
- event-propagation
- __tests__
- compass-to-google-this-event
- compass-to-google
- google-sync
- import
- init
- notify/handler
- public-watch-notifications
- records
- watch
- user
- controllers
- services
- scripts
- src
- __tests__/integration
- commands
- common
- migration-support
- migrations
- testing
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
120 | 129 | | |
121 | 130 | | |
122 | 131 | | |
| |||
127 | 136 | | |
128 | 137 | | |
129 | 138 | | |
| 139 | + | |
130 | 140 | | |
131 | 141 | | |
132 | 142 | | |
| |||
This file was deleted.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
| 107 | + | |
| 108 | + | |
108 | 109 | | |
109 | 110 | | |
110 | 111 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
| 23 | + | |
27 | 24 | | |
28 | 25 | | |
29 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
47 | 49 | | |
48 | 50 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
| 51 | + | |
| 52 | + | |
58 | 53 | | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
| 54 | + | |
63 | 55 | | |
64 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
65 | 61 | | |
66 | 62 | | |
67 | 63 | | |
| |||
261 | 257 | | |
262 | 258 | | |
263 | 259 | | |
264 | | - | |
| 260 | + | |
265 | 261 | | |
266 | 262 | | |
267 | 263 | | |
| |||
279 | 275 | | |
280 | 276 | | |
281 | 277 | | |
282 | | - | |
| 278 | + | |
283 | 279 | | |
284 | 280 | | |
285 | 281 | | |
| |||
This file was deleted.
0 commit comments