Rayrun
← Back to Discord Forum

Playwright vs axios

rajucheers
rajucheers

Hello all, is there a benefit we get out of using api testing using axios library vs PW. Appreciate thoughts

This thread is trying to answer question "What are the benefits of using axios library vs Playwright for API testing?"

10 replies

@rajucheers I m using Axios too . With Axios ans State mechanism my tests so speed and more manageable

butchmayhew
butchmayhew

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
rajucheers

interesting thoughts

rajucheers
rajucheers

@yusufozt. , what is State mechanism?

@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

}

By the way axios interceptors are useful

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.

rajucheers
rajucheers

Ok

I used both axios and playwright. One disadvantage that I see with playwrifght. If I use another context to api to add the auth another tracer is added to html reporter.

refactoreric

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

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

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 luc@ray.run.