playwright-api-test-demo
playwright-api-test-demo copied to clipboard
futureOpenCheckinDate when running tests in parallel with multiple workers could overlap
Hello,
https://github.com/playwrightsolutions/playwright-api-test-demo/blob/4ebe5c14c67bd8d67fbcf3be111628ad5e3c2422/lib/datafactory/booking.ts#L45
I am afraid that this method(futureOpenCheckinDate) can cause problems when tests for DELETE and PUT endpoints are executed in parallel, actually, I encountered it myself and spent one hour debugging it :)
@pajdekPL
- What exactly is the error message you are seeing?
- Which Part are you working through on the guide?
I believe this is something I have accounted for in part 6, when I utilize the .toPass() method on the expect, which is like a retry for a code block. I was seeing 409 response codes returned because I was trying to create a booking for dates that already exist, the .toPass() will basically try again if it hits an error within the datafactory method. If you still see it failing from pulling down this latest codebase (main branch) please do let me know, I have some other ways to make it more resilient that will make it into future articles :)
When I was writing this issue I hadn't reached to the part 6. Now I see your comment about that:
"This is here because if I run my tests in parallel the future date may get booked before the booking code runs resulting in 409 response codes." And you wrapped it using expect and toPass, so it "somehow" solves the mentioned problem ;)
I learned from this "bug" a lot to be more careful about asynchronous methods that can be executed in multiple tests in parallel, especially if those methods mess up with backend data. It could be a source of flakiness. So I am glad I hadn't had it hidden by the expect.toPass method earlier(for example in the part 2). Maybe you can just elaborate more about this kind of situation in the future, I think it could be one of the most significant sources of trouble for beginners ;)