I have a app that consumes a POST to the same api twice. How can I assert multiple request bodies in this manner?
This thread is trying to answer question "How can I assert multiple request bodies when my app makes two POST requests to the same API endpoint?"
maybe write your custom matcher that takes in array of requests and iterates over them verifying that all look good
https://playwright.dev/docs/test-assertions#add-custom-matchers-using-expectextend
https://playwright.dev/docs/network#network-events
can you use this?
I can not do the below in the callback of the on
event.... the same event fires twice and there is no way to for me to assert these separately
const assert1 = JSON.stringify({name: 'attr1', description: 'desc1' });
const assert2 = JSON.stringify({name: 'attr2', description: 'desc2' });
expect(response1.postData()).toEqual(assert1);
expect(response2.postData()).toEqual(assert2);
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].