Repository navigation
chore: migrate tests from mocha to vitest (PRE-3838) - #281
marceloprerender wants to merge 3 commits into
Conversation
Replace mocha 6 with vitest 4.1.11. done callbacks become awaited promises with the assertions moved after the await; vitest.config.js unsets PRERENDER_SERVICE_URL so the suite is hermetic, and runs test files serially because both Express support apps bind the same port. Travis now runs on Node 20, the minimum Vitest 4 supports. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Tests only ran inside the publish job on push to master, so a broken suite was first seen after merge and blocked the release. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Test planWhat changed
Preconditions — Node ≥ 20. 1. [local] The suite runs the same 39 tests
2. [local] Converted
|
| Behavior | Covered by | Command | Gap |
|---|---|---|---|
| Middleware behavior | test/index-spec.js, test/express3-spec.js, test/express4-spec.js (unchanged assertions, 93 in index-spec.js) |
npm test |
none new |
Risks / not covered
.travis.ymlwas bumped to Node 20, but Travis is probably dead for this repo; it may be worth deleting instead.- Test files run serially, because both support apps bind port 3000 when loaded.
No ticket · commit 0d20ec1 · regenerate with /test-plan 281
Review summaryReviewed in three independent lanes: correctness (code-review skill, high effort), conventions (project reviewers), and comments. Verdict: request changes. One item blocks: correctness #1, a one-line Must fix — correctness
Out of scope: older code this PR only touches, and dropped suggestionsOlder code (the same pattern exists on
Dropped suggestions (all from refactor-advisor):
Reviewer coverage note: |
vitest.config.js requires vitest, a devDependency consumers don't have. .github already shipped before this PR; the new test workflow would have joined it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Thanks @marcin-prerender. Fixed in a475ce5: While checking with I'm leaving the out-of-scope items for later. Moving the inline resets into |
What
Replaces Mocha 6 with Vitest 4.1.11 and adds a pull-request test workflow. Until now the tests only ran inside the publish job on push to
master.Same tests, same results
Mocha on
master: 39 passing. Vitest on this branch: 39 passed, with the same assertions (93 inindex-spec.js). The run used a cleannpm ci.Changes
donecallbacks are now awaited promises, and the assertions run after theawait. Before, a failing assertion inside a callback surfaced as an uncaught exception; now it fails its own test.vitest.config.jsunsetsPRERENDER_SERVICE_URL, so the suite is hermetic (it also passes with the variable set to a bogus URL). It runs test files serially because both Express support apps bind port 3000 when loaded.importfromvitest, because Vitest 4 can't berequired. Everything else staysrequire. assert, sinon, nock and supertest are kept..github/workflows/test.ymlrunsnpm teston PRs againstmaster, on Node 20, with the same install steps as the publish job..travis.yml: Node 10 → 20, since Vitest needs Node 20 or newer. The runtimeenginesfield is untouched; Vitest is a devDependency only.🤖 Generated with Claude Code