Repository navigation
Feature request: Project-level reusable authentication with Playwright storageState #4
Replies: 1 comment
|
Thank you for the detailed proposal. This is the authentication model we want WrightTest to support. We have implemented the MVP in the current development version and are validating it before release. One important design decision is that authentication is not stored as one global How to configure reusable authentication1. Create an EnvironmentOpen:
An Environment is a named set of variables for one target system. It is not a Docker or server environment. For example: The variable names are flexible. They can be used in check URLs and steps as An Environment is required because WrightTest keeps a separate authenticated state for every Project + Environment combination. 2. Create a dedicated Login checkCreate a normal check named, for example, Configure it as follows:
Recommended assertions:
The assertion is required. A successful click on the sign-in button alone does not prove that authentication completed. Login, logout, registration, password reset, guest, and negative authentication checks should keep reusable authentication disabled so that they always start unauthenticated. 3. Configure the authentication profileOpen:
Then:
WrightTest runs the Login check in a clean browser context without an old authentication state. If every step and assertion passes, WrightTest captures the Playwright browser state, including cookies, local storage, and IndexedDB authentication data. When the refresh completes, the status changes to Available. The successful refresh is also stored as a regular run with step results, screenshots, and a trace, so it can be inspected when necessary. 4. Use the profile in authenticated checksFor each regular authenticated check:
WrightTest creates a new isolated browser context for every check and initializes it with a copy of the saved authentication state. Checks remain independent; the browser context itself is never shared between runs. The same authentication state is used consistently by:
This prevents a situation where a check runs as an authenticated user but validation or recording unexpectedly opens the login page. Refresh and failure behaviorAuthentication refresh is manual in the MVP. Refresh the profile when:
A refresh uses last-known-good behavior:
Security and permissionsPlaywright
MVP scopeThe first version intentionally supports:
The MVP does not yet include automatic session-expiry detection, automatic refresh, multiple profiles for one Environment, shared authentication across projects, setup-check chains, or importing/exporting raw authentication state. So, for the message "Create an environment before configuring reusable authentication", the required first step is to create a project Environment such as |
Uh oh!
There was an error while loading. Please reload this page.
Hi Alex,
first of all, thanks for WrightTest. I've recently deployed it as a self-hosted instance and I'm currently evaluating it for automated testing of our web applications.
One feature that would be very useful for testing authenticated applications is project-level reusable authentication, ideally based on Playwright's
storageState.Use case
We have applications where almost every page requires authentication.
In WrightTest, I'd like to structure the project like this:
Currently, as far as I understand, every check creates a new browser context, so each check has to repeat the complete login flow.
For a project containing many checks this adds unnecessary execution time and also duplicates the login steps across all checks.
Suggested behavior
It would be great if a project could optionally select one existing check as its Authentication / Setup check.
After successfully running this check, WrightTest could save the Playwright authentication state:
Other checks in the project could then create their browser context using the stored state:
This would allow every check to remain independent while starting from an authenticated state.
Possible UI
Something like this in Project Settings:
Existing WrightTest Environments could still be used for credentials:
so there would be no need for a separate credentials mechanism.
Expired sessions
A simple first implementation could just allow the user to manually click Refresh authentication when the session expires.
A future enhancement could automatically rerun the authentication check when the stored session is no longer valid.
Playwright already recommends reusing authenticated browser state for this type of scenario, so this seems like a natural fit for WrightTest.
Would you consider adding something like this?
Thanks!
All reactions