Skip to content

Vitest followup: switch to happy-dom, cleanup/fixes to mocks#21359

Merged
davelopez merged 18 commits intogalaxyproject:devfrom
dannon:vitest-cleanup
Nov 25, 2025
Merged

Vitest followup: switch to happy-dom, cleanup/fixes to mocks#21359
davelopez merged 18 commits intogalaxyproject:devfrom
dannon:vitest-cleanup

Conversation

@dannon
Copy link
Copy Markdown
Member

@dannon dannon commented Nov 25, 2025

  • Switch test environment from jsdom to happy-dom (faster, lighter)
  • Remove jsdom and jsdom-worker packages
  • Remove unnecessary polyfills that happy-dom provides natively (setImmediate, structuredClone, HTMLDialogElement, ResizeObserver, IntersectionObserver)
  • Mock KaTeX to avoid quirks mode warning during tests
  • Consolidate duplicate test mocks into shared __mocks__ directories
  • Update ro-crate-zip-explorer to 0.4.1 to fix sourcemap warnings (thanks @davelopez!)

🔥 With this, on my macbook I'm seeing ~22 seconds for the whole yarn test now. 🔥

image

How to test the changes?

(Select all options that apply)

  • I've included appropriate automated tests.
  • This is a refactoring of components with existing test coverage.
  • Instructions for manual testing are as follows:
    1. [add testing steps and prerequisites here if you didn't write automated tests covering all your changes]

License

  • I agree to license these and all my past contributions to the core galaxy codebase under the MIT license.

Added shared config mock to reduce duplication across tests. The mock provides
a flexible default config that tests can override using setMockConfig().

Removed unused mocks:
- font.js and style.js: Vite handles CSS and font imports natively
- src/app/__mocks__/index.js: All tests use inline mocks with test-specific data
- WorkflowRunSuccess.vue: Test uses inline mock instead
Converted Login, Register, and CitationsList tests to use the shared config
mock instead of inline duplicates. Tests can now call setMockConfig() to
customize config values while sharing the mock implementation.
Four tests were using empty config {} so they just use the shared mock now.
Two tests both used toolbox_auto_sort so they now share that config too.
happy-dom is faster and lighter with better standards compliance. Should
make tests run quicker overall.
Missing closing bracket in attribute selectors that jsdom was lenient about.
Happy-dom natively supports setImmediate, structuredClone, and
HTMLDialogElement, so we can remove those polyfills. Mock KaTeX
entirely since we don't test it directly - this avoids the quirks
mode warning it logs at module load time.
@github-actions github-actions Bot added this to the 26.0 milestone Nov 25, 2025
@dannon dannon changed the title Vitest cleanup: switch to happy-dom, cleanup/fixes to mocks Vitest followup: switch to happy-dom, cleanup/fixes to mocks Nov 25, 2025
Copy link
Copy Markdown
Contributor

@davelopez davelopez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool!
Just some minor comments, mostly out of curiosity.

Comment thread client/src/composables/__mocks__/config.ts
Comment thread client/src/components/Panels/ToolBox.test.js
@davelopez davelopez merged commit e01379d into galaxyproject:dev Nov 25, 2025
34 of 35 checks passed
@github-actions
Copy link
Copy Markdown

This PR was merged without a "kind/" label, please correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants