Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.
This repository was archived by the owner on Sep 11, 2025. It is now read-only.

[QUESTION] how do I properly configure with it,jestPlaywrightConfig().. #494

@onno-amsterdam

Description

@onno-amsterdam

I'm trying to pass jetPlaywrightConfig in a test, however I don't seem to get it to work.

This is my test:

import { JestPlaywrightConfig } from 'jest-playwright-preset';

describe('TEST 001', () => {
     const config: JestPlaywrightConfig = { 
                devices: ['iPhone 11'], 
                contextOptions: { locale: 'nl-NL' }, 
                exitOnPageError: true,  // required
                browsers: ['chromium'], // required
                collectCoverage: false, // required
      }

      // without the required I get a property missing error
    
     it.jestPlaywrightConfig(config, 'WITH CONFIG', async () => {
             await page.goto('http://google.com');
             await page.waitForTimeout(10000);
     }
}

Expected: the test launches in a browser sized to iPhone 11 with nl-NL locale.
Actual: when I run the test I see a browser open, then a second. Both have the default size. The test is executed inside the first browser.

This is my jest.config.js:

module.exports = {
    verbose: true,
    preset: 'jest-playwright-preset',
    transform: {
        '^.+\\.ts$': 'ts-jest',
    },
    testTimeout: 60000,
    testRunner: 'jasmine2',
    globalSetup: './globalSetup.js',
    setupFilesAfterEnv: [
        "jest-allure/dist/setup"
    ],
    testEnvironmentOptions: {
        'jest-playwright': {
            launchOptions: {
                headless: false
            }
        }
    },
}

When I put the device and locale option inside the jest.config then I see the test run properly in a iPhone 11 sized browser.

Am I missing something in the way I use it.jestPlaywrightConfig()? Thank you.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions