refactor(types): migrate from tsd to tstyche#95
Open
Puppo wants to merge 4 commits into
Open
Conversation
- Replace tsd dependency with tstyche - Update test:typescript script - Convert types/plugin.test-d.ts to types/plugin.tst.ts - Update assertion syntax to use tstyche fluent API - Convert plugin.d.ts from CommonJS-style 'export =' to ESM 'export default' to match the package's ESM module mode (required by tstyche/NodeNext) Refs: nearform/fastify-slow-down#625
- actions/checkout: v4 → v6 - actions/setup-node: v3 → v6 - fastify/github-action-merge-dependabot: keep on the v3 major (no v6 has been released for this action) - Node.js test matrix: add 24.x and 26.x alongside the existing 20.x and 22.x
Group the assertions into nested describe() blocks — one per public API
surface (plugin registration, FastifyInstance decorators, FastifyReply
decorator) — and wrap each scenario in a named test().
The reporter now shows 6 named tests across 4 groups:
fastify-html
plugin registration
+ registers via the default export
+ accepts the async option
FastifyInstance decorator: html()
+ returns a string for any template literal input
FastifyInstance decorator: addLayout()
+ accepts a render function and an optional skipOnHeader option
FastifyReply decorator: html()
+ returns FastifyReply for any template literal input
+ can be used inside a route handler with default options
The two registration-only tests and the route-handler smoke test are
type-checked even though they have no expect() assertion — tstyche still
verifies the code in the test body compiles. 3 explicit type assertions
remain.
Each test previously repeated the same three lines:
const server = fastify()
server.register(fastifyHtml, ...)
server.after(() => { ... })
Extract a callback-style helper that owns all of that, so each test
body becomes a single withServer((server) => { ... }) call. The
helper also defaults options to {} so registration smoke tests stay
one-liner.
Reporter output is unchanged: 6 named tests in 4 groups, 3 type
assertions.
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
Migrates type tests from
tsdtotstyche. Also bumps GitHub Actions to v6 and extends the CI Node.js matrix to 24.x, and 26.x.