This thread is trying to answer question "What are the benefits of using axios library vs Playwright for API testing?"
I've got a suite of 1400+ api tests using only playwright api methods, have no issues, suite is fast, the built in test runner and reports with trace files make debugging easy. I haven't used axios directly but I'm pretty sure that's whats being used underneath the playwright implementation.
@rajucheers Saving axios response to state but you can also run states with Playwright api For e.g saving responses to States and calling them in tests
export const ReportsState = { //API createdDashboardId: {} as string, createdDashboardTitle: {} as string, createdWidgetName:{} as string,
//E2E
createdFakeWidgetName: {} as string,
createdFakeDashboardName: {} as string,
updatedFakeWidgetName: {} as string,
fakeQuadrantNumber: {} as any
}
We use axios within our playwright framework to do our api handling / calls. I've built out two similar services that utilize axios vs playwright api tools and found that axios provides a little more speed and better async handling for some of our specific api endpoints that require multiple steps.
For easier troubleshooting I'd recommend Playwright's APIRequestContext (request
or page.request
) since its API requests and responses are included in Playwright's trace files. I don't think that's the case with axios.
https://playwright.dev/docs/trace-viewer-intro
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].