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
Similar request to #32748, but I'd like it expanded to support 3rd party request clients such as Axios. It seems like you're planning to implement that request, so my request is to expose whatever function you end up using to attach request info to test steps. I don't mind if I have to transform the Axios/whatever data structure to fit your API, I understand maintaining such a function to support various popular libraries would be a burden.
Example
I guess I'd use it much like my current solution below, except instead of creating new steps with the request/response info jammed into the step name, I'd do something like:
This function would be registered as an interceptor for responses for our Axios instances.
Motivation
We already used Playwright for UI tests for a long time before we started doing API testing with it, so we've built up quite a library of functions for interacting with our API and they all use a customised instance of Axios. When we started doing API stuff in the same framework, we had a look at the built-in HTTP client but it was missing certain config that we need (more on that below), so I hacked a slightly dodgy workaround for attaching requests/responses to the test steps. This function gets set as a request & response interceptor on Axios:
It's not perfect (you have to inspect HTML in the report to see more than the first few dozen chars of the 'step name', and it does eventually truncate) but it's done the job well enough for now:
Why we stuck with Axios rather than ApiRequestContext
I'm curious, what's that config that you're missing in the builtin API Client? What would we need to build so you can migrate from Axios?
These are the three reasons I found to stick with Axios during my little investigation in September.
Interceptors - we use these a bunch to do things like refresh auth tokens and transform error responses for cleaner logging. I keep finding more uses for them and don't want to give them up.
The function to create an ApiRequestContext is async. We instantiate our axios clients inside class constructors, where you can't use await, so changing clients would seem to involve refactoring everything.
We pass the below option to axios.create() to work around some deficiency in the local dev environment. At the time I couldn't find a way to do the same thing with ApiRequestContext. It looks like maybe we could do it with your clientCertificates option now, but I'm not familiar with the issue:
The step attachments from #32748 should cover your current needs. I leave this request open though, as we could provide better support for API testing and have third-party libraries represented in the traces and network tab of the trace viewer.
We pass the below option to axios.create() to work around some deficiency in the local dev environment. At the time I couldn't find a way to do the same thing with ApiRequestContext.
I think you should be able to achieve this with ignoreHTTPSErrors:
🚀 Feature Request
Similar request to #32748, but I'd like it expanded to support 3rd party request clients such as Axios. It seems like you're planning to implement that request, so my request is to expose whatever function you end up using to attach request info to test steps. I don't mind if I have to transform the Axios/whatever data structure to fit your API, I understand maintaining such a function to support various popular libraries would be a burden.
Example
I guess I'd use it much like my current solution below, except instead of creating new steps with the request/response info jammed into the step name, I'd do something like:
This function would be registered as an interceptor for responses for our Axios instances.
Motivation
We already used Playwright for UI tests for a long time before we started doing API testing with it, so we've built up quite a library of functions for interacting with our API and they all use a customised instance of Axios. When we started doing API stuff in the same framework, we had a look at the built-in HTTP client but it was missing certain config that we need (more on that below), so I hacked a slightly dodgy workaround for attaching requests/responses to the test steps. This function gets set as a request & response interceptor on Axios:
It's not perfect (you have to inspect HTML in the report to see more than the first few dozen chars of the 'step name', and it does eventually truncate) but it's done the job well enough for now:
Why we stuck with Axios rather than ApiRequestContext
@Skn0tt asked:
These are the three reasons I found to stick with Axios during my little investigation in September.
await
, so changing clients would seem to involve refactoring everything.axios.create()
to work around some deficiency in the local dev environment. At the time I couldn't find a way to do the same thing with ApiRequestContext. It looks like maybe we could do it with yourclientCertificates
option now, but I'm not familiar with the issue:Thank you for your consideration ❤
The text was updated successfully, but these errors were encountered: