You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In MSW, a mock handler can access the response resolver info. For example, it can access the request body to change the response based on the request. Access to that request body is only possible through an async function call to json().
http.post("/some/path",async({ request })=>{constrequestJson=awaitrequest.json();// Do something with the request, such as producing a response based on it.return ...
});
In Orval, PR #1375 made it possible for the override in a MSW mock handler to be a function, and Orval passes the response resolver info to that function. However, Orval requires a synchronous method that returns a response object. It does not allow async functions.
Hence, it's not possible to migrate the above to Orval.
getSomePathMockHandler(async({ request })=>{// This does not type-check. Orval does not allow a Promise<SomeResponse> return type.constrequestJson=awaitrequest.json();// Do something with the request, such as producing a response based on it.return ...
});
What happens?
The above code does not type-check, because Orval does not allow response type to be Promise<SomeResponse>.
What were you expecting to happen?
The above code should type-check. It should be possible to pass both a sync or async method, in the same way MSW allows this.
What are the steps to reproduce this issue?
In MSW, a mock handler can access the response resolver info. For example, it can access the request body to change the response based on the request. Access to that request body is only possible through an
async
function call tojson()
.In Orval, PR #1375 made it possible for the override in a MSW mock handler to be a function, and Orval passes the response resolver info to that function. However, Orval requires a synchronous method that returns a response object. It does not allow
async
functions.Hence, it's not possible to migrate the above to Orval.
What happens?
The above code does not type-check, because Orval does not allow response type to be
Promise<SomeResponse>
.What were you expecting to happen?
The above code should type-check. It should be possible to pass both a sync or
async
method, in the same way MSW allows this.Any logs, error output, etc?
N/A
What versions are you using?
Operating System: MacOS
Package Version: 0.29.1
Browser Version: Node.js 20
This should be trivial to fix, so I'll open a simple PR.
The text was updated successfully, but these errors were encountered: