Skip to content
Discussion options

You must be logged in to vote

Right—the explicit handler pattern is only practical for a single-route unit test. For a multi-route integration test, the in-memory Builder snapshot is the better fit.

A file such as routes/users/[id].tsx is registered as a parameterized route, so the test request must use a concrete path such as /users/123, not /users/[id]. The other two easy gotchas are that Builder resolves routes/ from Deno.cwd() unless root is set, and the snapshot must be applied to the same app after .fsRoutes():

const builder = new Builder({ root: projectRoot });
const applySnapshot = await builder.build({ snapshot: "memory" });
const app = new App().fsRoutes();
applySnapshot(app);

const response = await app.han…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@Toby222
Comment options

@Toby222
Comment options

Comment options

You must be logged in to vote
1 reply
@Toby222
Comment options

Answer selected by Toby222
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants