You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be helpful if we could easily combine/merge multiple storage states in an arbitrary way. This could be done by allowing both the storageState fixture, and browser.newContext({ storageStage: ... }), to accept an array of state values, which are then logically merged into a single storage state object.
In the case of conflicting values, the last object arg containing a conflicting item would take precedence, similar to Object.assign.
Motivation
A similar proposal has been previously discussed and dismissed: #17744
The solution there was to create different storage state files at different levels of authentication. However, in my use case, this is infeasible, as I need to create many combinations of different storage items, comprising authentication for multiple different domains, and individual site settings which may be toggled on and off differently for each test case. This would mean a combinatorial explosion of required setup runs to generate the authX.json files.
Currently my solution is a combination of:
In a setup script, perform the first login and save as authA.json. then perform the second login, save as authA+B.json, etc.
At the start of the test, set config values manually in localstorage, e.g.:
This is somewhat cumbersome, and doesn't fully solve the issue of combining logins arbitrarily in an efficient way.
I believe the actual logic for merging multiple StorageState objects is fairly trivial (in fact I've already written it), but would prefer not to maintain this code & required unit tests within my own project.
The text was updated successfully, but these errors were encountered:
🚀 Feature Request
It would be helpful if we could easily combine/merge multiple storage states in an arbitrary way. This could be done by allowing both the
storageState
fixture, andbrowser.newContext({ storageStage: ... })
, to accept an array of state values, which are then logically merged into a single storage state object.Example
Or mixing literal objects with files:
In the case of conflicting values, the last object arg containing a conflicting item would take precedence, similar to
Object.assign
.Motivation
A similar proposal has been previously discussed and dismissed: #17744
The solution there was to create different storage state files at different levels of authentication. However, in my use case, this is infeasible, as I need to create many combinations of different storage items, comprising authentication for multiple different domains, and individual site settings which may be toggled on and off differently for each test case. This would mean a combinatorial explosion of required setup runs to generate the
authX.json
files.Currently my solution is a combination of:
authA.json
. then perform the second login, save asauthA+B.json
, etc.This is somewhat cumbersome, and doesn't fully solve the issue of combining logins arbitrarily in an efficient way.
I believe the actual logic for merging multiple
StorageState
objects is fairly trivial (in fact I've already written it), but would prefer not to maintain this code & required unit tests within my own project.The text was updated successfully, but these errors were encountered: