What are the reasons for the storage state generated in global setup not being applied to the browser context for test cases in CI?


Why Your Storage State Might Not Apply

You might be wondering why the storage state you generated in the global setup isn't being applied to the browser context for your test cases in CI. There could be a few reasons for this.

Project Dependencies

Let's say you have two projects: 'logged in chromium' and 'logged out chromium'. The 'logged in chromium' project depends on the setup project and uses the storageState option to apply the storage state on its browser context. But if a test case belongs to the 'logged out chromium' project, which doesn't depend on the setup project or use the storageState option, it won't have access to the stored state.

Global Setup and Teardown

If you want traces or artifacts from your tests, you should use project dependencies instead of globalSetup and globalTeardown. These methods don't produce such outputs.

Configuration File

Your configuration file (playwright.config.ts) should correctly specify globalSetup along with baseURL and storageState options. If these are incorrectly specified or missing, tests might start without being authenticated because they lack access to the populated storageState from global setup.

Here's an example of a correctly specified configuration file:

import { PlaywrightTestConfig } from '@playwright/test';

const config: PlaywrightTestConfig = {
  baseURL: 'https://ray.run',
  globalSetup: './global-setup.ts',
  projects: [
      name: 'Chromium',
      use: {
        browserName: 'chromium',
        storageState: './storage-state.json'

export default config;

So, make sure you're using dependencies correctly and specifying necessary options in your configuration file. This will ensure all test cases have access to the stored state generated during global setup.


Thank you!
Was this helpful?
Still have questions?

If you still have questions, please ask a question and I will try to answer it.

Related Discord Threads

Related Questions

AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.