playwright-testing-library
playwright-testing-library copied to clipboard
✨ Support the configure API for locator queries
This was my first go at implementing configure()
for the Locator
queries from a couple weeks back. I decided to try to synchronize the configuration state across all the implementations, but in retrospect, I think that's probably a little silly. I think that's why the tests are failing on CI as they work fine locally.
Anyways, I attempted to implement it with a janky mutable let
as we did for the "vanilla" playwright stuff which was tricky in the case of @playwright/test because we evaluate the Testing Library script eagerly in the automatic worker fixture which prevents someone from being able to invoke configure()
in a beforeEach
like is possible with the vanilla implementation. To account for that, even though it's probably an edge case, I also added configurePage
which ephemerally applies a configuration for a single test. What I was after was the same exact API and behavior that Testing Library provides, and I ended up with something perfectly different and confusing (and broken) 🙃
At the end of the day, I should have dug deeper into the @playwright/test documentation first to determine whether we can leverage something that's thread-safe within the context of the worker stuff it supports. I think the way to go is fixture overrides that should hopefully allow us to override the worker fixture that adds the addInitScript
at the correct time and place, including scoping configuration to tests via local configuration.
Oh yeah, and I refactored stuff into a few separate modules and probably should have waited on that.