Skip to content

test: replace jasmine browser runner with vitest + jsdom#869

Merged
tkirda merged 2 commits into
masterfrom
test/vitest-jsdom-port
May 20, 2026
Merged

test: replace jasmine browser runner with vitest + jsdom#869
tkirda merged 2 commits into
masterfrom
test/vitest-jsdom-port

Conversation

@tkirda
Copy link
Copy Markdown
Member

@tkirda tkirda commented May 20, 2026

Summary

PR-1 of the modernization plan: make the test suite headless and CI-ready without touching src/jquery.autocomplete.js. All 26 original Jasmine specs are ported (31 it() cases), and the legacy spec/ directory (vendored Jasmine 1.3.1 + 2.0.1, runner.html) is removed. Now npm test runs everything headless in ~3s and exits nonzero on failure.

This is intentionally tooling-only — the plugin source is unchanged. Source modernization comes in a later PR after CI is green.

What changed

  • Vitest + jsdom: vitest.config.js (jsdom env), test/setup.js attaches a single jQuery instance to globalThis / window, registers jquery-mockjax, then loads the UMD plugin so it binds to the same instance.
  • Specs ported: test/autocomplete.test.jsbeforeEach(done)await new Promise(...), spyOnvi.spyOn. Same behavioral coverage as the originals.
  • Dependencies: added vitest@4.1.6, jsdom@29.1.1, jquery@3.7.1, jquery-mockjax@2.6.0 as dev deps. jQuery and mockjax versions match what spec/runner.html loaded from CDN.
  • Scripts: added npm test and npm run test:watch; broadened lint / format globs to include test/.
  • ESLint config rename: eslint.config.jseslint.config.mjs to silence Node's ESM-reparse warning without adding "type": "module" to package.json (that would break CommonJS consumers of the dist UMD bundle).
  • Removed: spec/ directory in full.
  • Docs: new CLAUDE.md with project shape, commands, test setup, release flow, non-obvious architecture, and a Conventional Commits requirement for future work.

Notes worth flagging in review

  • pool: "threads" is pinned in vitest.config.js — Vitest 4's default forks pool on Windows times out the worker handshake when the setup file does heavy synchronous work (jQuery + mockjax + UMD plugin load). Comment in the config explains. Don't switch pools without re-verifying.
  • grunt + grunt-contrib-uglify still in devDependencies. They go away in PR-2 (build refresh). Most of the open npm audit advisories trace back to those — not worth touching here.
  • No source changessrc/jquery.autocomplete.js is untouched.

Test plan

  • npm test — 31/31 pass, ~3s
  • npm run lint — clean
  • npm run format — no diffs
  • Reviewer sanity-checks no spec was dropped during the port (count went 26 → 31 because some originals tested multiple assertions in one it; a few were split where it read better)

🤖 Generated with Claude Code

tkirda-bison and others added 2 commits May 19, 2026 21:24
PR-1 of the modernization plan: makes the test suite headless and CI-ready
without touching src/jquery.autocomplete.js.

- Add vitest, jsdom, jquery@3.7.1, jquery-mockjax@2.6.0 dev deps (jQuery +
  mockjax versions match what spec/runner.html loaded from CDN).
- test/setup.js attaches a single jQuery instance to globalThis/window,
  registers mockjax against it, then loads the UMD plugin so it binds to the
  same instance. Silences mockjax's per-request console logging.
- vitest.config.js pins pool: "threads" — the default "forks" pool on Windows
  times out the worker handshake when the setup file does heavy synchronous
  work (jQuery + mockjax + UMD plugin load).
- Port all 26 Jasmine specs to test/autocomplete.test.js (31 it() cases):
  beforeEach(done) -> await new Promise(...), spyOn -> vi.spyOn.
- Add npm test / test:watch scripts; broaden lint and format globs to test/.
- Rename eslint.config.js -> eslint.config.mjs to silence Node's ESM-reparse
  warning without adding "type": "module" to package.json (which would break
  CommonJS consumers of the dist UMD bundle).
- Remove spec/ (vendored Jasmine 1.3.1 + 2.0.1, runner.html, original spec).

grunt + grunt-contrib-uglify still in devDependencies; PR-2 replaces them.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Documents project shape (single-file UMD plugin), commands, test setup
(vitest + jsdom + mockjax), release/version flow, non-obvious architecture
(UMD wrapper, dual plugin name, defaults merge, response normalization,
caching guards), source style (intentionally ES5 inside the IIFE), and the
Conventional Commits requirement.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@gongph
Copy link
Copy Markdown

gongph commented May 20, 2026 via email

@tkirda tkirda merged commit 4652fe9 into master May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants