<p dir="auto">I'm hoping to utilize the storageState functionality discussed here: <a href="https://playwright.dev/docs/auth#session-storage" rel="nofollow">https://playwright.dev/docs/auth#session-storage</a></p>
<p dir="auto">I want to log in once, store the state in a json file, and then use it for all subsequent tests in a spec.</p>
<p dir="auto">The problem is that the login credentials json / state info is only valid in our application for a few hours. It will then fail to login in when I try to use it.</p>
<p dir="auto">As a result, I cannot just store it in a hard coded manner indefinitely. I need an initial test to log in, save the storageState to JSON, and then for my tests to use it.</p>
<p dir="auto">The page linked above refers to this flow but provides no working example:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Logging in via the UI and then reusing authentication state can be combined to implement login once and run multiple scenarios. The lifecycle looks like:

Run tests (for example, with npm run test).
Login via UI and retrieve authentication state.
In Jest, this can be executed in globalSetup.
In each test, load authentication state in beforeEach or beforeAll step.
This approach will also work in CI environments, since it does not rely on any external state."><pre class="notranslate"><code class="notranslate">Logging in via the UI and then reusing authentication state can be combined to implement login once and run multiple scenarios. The lifecycle looks like:

Run tests (for example, with npm run test).
Login via UI and retrieve authentication state.
In Jest, this can be executed in globalSetup.
In each test, load authentication state in beforeEach or beforeAll step.
This approach will also work in CI environments, since it does not rely on any external state.
</code></pre></div>
<p dir="auto">Could some example code be added? How do you implement it so an initial log in test will always run first, store the data, and then let all tests use it?</p>
<p dir="auto">Do you support any version of Internet Explorer?</p>