test: replace jasmine browser runner with vitest + jsdom#869
Merged
Conversation
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>
|
这是来自QQ邮箱的假期自动回复邮件。你好,我最近正在休假中,无法亲自回复你的邮件。我将在假期结束后,尽快给你回复。
|
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
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 (31it()cases), and the legacyspec/directory (vendored Jasmine 1.3.1 + 2.0.1, runner.html) is removed. Nownpm testruns 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.config.js(jsdom env),test/setup.jsattaches a single jQuery instance toglobalThis/window, registersjquery-mockjax, then loads the UMD plugin so it binds to the same instance.test/autocomplete.test.js—beforeEach(done)→await new Promise(...),spyOn→vi.spyOn. Same behavioral coverage as the originals.vitest@4.1.6,jsdom@29.1.1,jquery@3.7.1,jquery-mockjax@2.6.0as dev deps. jQuery and mockjax versions match whatspec/runner.htmlloaded from CDN.npm testandnpm run test:watch; broadenedlint/formatglobs to includetest/.eslint.config.js→eslint.config.mjsto silence Node's ESM-reparse warning without adding"type": "module"topackage.json(that would break CommonJS consumers of the dist UMD bundle).spec/directory in full.CLAUDE.mdwith 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 invitest.config.js— Vitest 4's defaultforkspool 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-uglifystill in devDependencies. They go away in PR-2 (build refresh). Most of the opennpm auditadvisories trace back to those — not worth touching here.src/jquery.autocomplete.jsis untouched.Test plan
npm test— 31/31 pass, ~3snpm run lint— cleannpm run format— no diffsit; a few were split where it read better)🤖 Generated with Claude Code