Rayrun
← Back to Discord Forum

Custom Fixtures & `storageState`

Hello all! I would like to use a custom fixture settingX to parameterize tests. I have defined an extended test as follows:

// test.ts
import { test as base } from '@playwright/test';
export type TestOptions = {settingX: string;};
export const test = base.extend<TestOptions>({
  settingX: ['Kuririn', { option: true }],
});

My PW config:

// playwright.config.ts
import { defineConfig } from '@playwright/test';
import type { TestOptions } from './test';

export default defineConfig<TestOptions>({
  projects: [
    {
      name: 'roshi',
      use: { settingX: 'Roshi' },
    },
    {
      name: 'yamucha',
      use: { settingX: 'Yamucha' },
    },
  ]
});

I would like to be able to use test.use as follows, but Playwright complains about the unknown fixture settingX for storageState:

test.use({
    storageState: async ({settingX}, use) => {
      //do something async with settingX
      use(derivedStorageStage);
    }
});

Am I missing something in the extension of base test?

This thread is trying to answer question "Why is Playwright complaining about the unknown fixture `settingX` for `storageState` when using a custom fixture to parameterize tests?"

0 replies

Related Discord Threads

TwitterGitHubLinkedIn
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.