test(dev-server-core): migrate from mocha/chai to node:test#3098
test(dev-server-core): migrate from mocha/chai to node:test#3098bennypowers wants to merge 6 commits into
Conversation
Replace mocha/chai/hanbi with node:test and node:assert/strict across all 14 test files (97 tests), test helpers, and the published `src/test-helpers.ts` utility. Key changes: - chai `expect` assertions to node:assert/strict - hanbi `stubMethod` to `mock.method` from node:test - `__dirname` to `import.meta.dirname` - Source imports (`../src/`) to dist imports (`../dist/`) - Test-local imports use `.ts` extension for strip-types compat - `context()` to `describe()` (mocha alias not in node:test) - mocha test script to `node --experimental-strip-types --test` Note: `src/test-helpers.ts` is a published utility exported via `exports["./test-helpers"]`. Its `fetchText` function now uses `node:assert` instead of `chai` for the status check -- pending team decision on whether this is acceptable. Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… assertion errors Replace assert.ok(x.includes(y)) with expectIncludes from test-helpers across all test files. Shows actual vs expected strings on failure instead of useless true/false. Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@bennypowers I made a couple of changes, quite small, but the one that removes the major update changset I think you'd like to check. Let me know if you agree with the changes. I also have another idea about test-helpers, but it's best to discuss it in a separate PR which I plan to create when this one is merged. Just giving you heads-up upfront that it might not be the final state before we release all of this. |
Summary
stubMethodwithmock.methodfrom node:testnode --experimental-strip-types --testsrc/test-helpers.tsto use node:assert instead of chai (breaking change, changeset included)Breaking change
src/test-helpers.tsis exported viaexports["./test-helpers"]. ItsfetchTextfunction now throwsnode:assert'sAssertionErrorinstead of chai's on non-200 responses. Functionally identical, different error class. Pending team decision on acceptability.Test plan