-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: type-safe msw endpoint helper #288
Conversation
http.get("*/api/v1/workspaces/:name/custom-instructions", () => { | ||
return HttpResponse.json({ prompt: "initial prompt from server" }); | ||
}), | ||
http.get( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a required change for this PR, but I am kinda wondering if we could even make a single wrapper function that can be used like this:
mockEndpoint("..etc...", () => {
return HttpResponse.json(...etc...)
})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably yes, I didn't want to dive too deep in on this attempt — it's a little fussy because MSW's http has methods for each HTTP method (put,post,get) etc, and we'd have to do a little glue work to support all of them correctly, but eventually it would be possible.
Pull Request Test Coverage Report for Build 13259167234Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
This is a supporting PR for #287 — while refactoring mocking, I noticed a few issues with our use of MSW, specifically around overly permissive wildcards, and aprtial path matches.
This PR introduces a type-safe helper,
mswEndpoint()
that uses thepaths
defined in the OpenAPI json to limit the user input.