Commit 0cab21d
chore: Migrate golden-layout tests from Karma to Jest (deephaven#2611)
Migrate golden-layout tests from Karma/Jasmine to Jest/TypeScript using
AI and a planning doc. Migration worked, I manually spot checked a bunch
of them for sanity and they seemed like it made wise choices, and even
uncovered a bug.
- Migrate all 21 test files from /test/.js to /src/tests/.test.ts
- Tests kept with same name, and same coverage
- Remove Karma configuration and legacy test files
- Enable previously skipped drag tests with jQuery mocks
- Fix bug in replaceChild that caused destruction errors
Changes
Test Migration
- Convert Jasmine syntax to Jest (spyOn → jest.spyOn, waitsFor/runs →
async/await)
- Add shared test utilities in src/test-utils/testUtils.ts
- Remove Karma devDependencies (babelify, browserify, karma-browserify,
watchify)
- Enabled Drag Tests
- Test count decreased, as cleanup is afterEach rather than deticated in
each test
The drag tests were skipped because jsdom doesn't support jQuery
dimension methods. Added mocks for $.fn.offset, $.fn.width, $.fn.height,
$.fn.outerWidth, $.fn.outerHeight, and
$.fn.is(':visible').
Bug Fix: replaceChild Event Listener Leak
When replaceChild() swapped a tab's content item, it directly assigned
the new reference without transferring event listeners. This caused "No
subscriptions to unsubscribe for event destroy" errors when destroying
the layout after drag-drop split operations.
Fix: Added Tab.setContentItem() method that properly transfers destroy
and titleChanged
listeners from the old content item to the new one.
Test Results
21 tests migrated, all passing.
Test Plan
- Manually spot check tests to compare coverage
- All golden-layout tests pass
- TypeScript compiles without errors
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: mofojed <4505624+mofojed@users.noreply.github.com>1 parent be78f72 commit 0cab21d
File tree
57 files changed
+3853
-4394
lines changed- .github/workflows
- packages/golden-layout
- plans
- src
- __tests__
- config
- controls
- items
- test-utils
- utils
- test
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
57 files changed
+3853
-4394
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
82 | 81 | | |
83 | 82 | | |
84 | 83 | | |
85 | 84 | | |
86 | 85 | | |
87 | 86 | | |
88 | | - | |
89 | 87 | | |
90 | 88 | | |
91 | 89 | | |
| |||
0 commit comments