Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] TypeError: Cannot read properties of undefined (reading 'project') when adding projects to playwright.config.js #34559

Open
senn opened this issue Jan 30, 2025 · 1 comment

Comments

@senn
Copy link

senn commented Jan 30, 2025

We have a working playwright setup for which we are using a custom reporter by a 3rd party.
This reporter requires the playwright config to use projects.

Whenever we add this to our config (in the use object):

projects: [
    {
        name: 'Automated Playwright tests',
    },
],

we encounter the following error: TypeError: Cannot read properties of undefined (reading 'project') when adding projects to playwright.config.js.

The error seems to be coming from PW itself, as even without our custom reporter, the error pops up when we add the projects to the config.

Reproducible on PW version 1.50.

Is there maybe a specific property that is expected in project objects, that we're missing?
We have tried adding quite a few properties, but can't seem to get solve the error. We've tried -on top of name- title, use, devices, ...

Full config:

/* global process */

// Prepare Playwright launch arguments
const launchArgs = ['--disable-dev-shm-usage', '--disable-gpu'];
if ('LOCAL' === process.env.ENVIRONMENT) {
    // Ignore certificate errors on local
    launchArgs.push('--ignore-certificate-errors');
}

// Prepare Playwright reporters - dedicated Zephyr reporter when env variable is set
let reporters;
if ('true' === process.env.PLAYWRIGHT_ZEPHYR_REPORTING_ENABLED) {
    reporters = [
        ['list'],
        [
            '@y9f-zephyr/reporter',
            {
                auth: {
                    username: process.env.PLAYWRIGHT_ZEPHYR_USERNAME,
                    password: process.env.PLAYWRIGHT_ZEPHYR_PASSWORD,
                    PatId: process.env.PLAYWRIGHT_ZEPHYR_PAT_ID,
                },
                zephyr: {
                    projectKey: process.env.PLAYWRIGHT_ZEPHYR_PROJECT,
                    testPlanKey: process.env.PLAYWRIGHT_ZEPHYR_TESTPLAN,
                    environment: process.env.ENVIRONMENT,
                },
            },
        ],
    ];
} else {
    reporters = [
        ['junit',
            {
                // Place the junit results somewhere our Jenkins pipeline will look for them
                outputFile: 'e2e/results/junit-results.xml',
                stripANSIControlSequences: true,
            },
        ],
        ['list'],
    ];
}

export default {
    use: {
        projects: [
            {
                name: 'Automated Playwright tests',
            },
        ],
        channel: 'chrome',
        headless: true,
        screenshot: 'only-on-failure',
        video: 'on-first-retry',
        ignoreHTTPSErrors: true,
        contextOptions: {
            reducedMotion: 'reduce',
        },
        launchOptions: {
            executablePath: process.env.CHROMIUM_BIN,
            args: launchArgs
        },
        trace: 'retain-on-failure'
    },
    workers: 1,
    updateSnapshots: 'missing',
    reporter: reporters,
    retries: 1,
    testDir: 'e2e/specs',
    snapshotDir: 'e2e/snapshots',
    testMatch: '**/*.spec.js',
    outputDir: 'e2e/results',
};
@senn senn changed the title TypeError: Cannot read properties of undefined (reading 'project') when adding projects to playwright.config.js [BUG] TypeError: Cannot read properties of undefined (reading 'project') when adding projects to playwright.config.js Jan 30, 2025
@agg23
Copy link
Contributor

agg23 commented Jan 30, 2025

Please provide a full repo with a reproduction. I am not able to trivally produce your issue.

Two things I noticed: You're not using defineConfig as seen here. projects is a key on the root object, not under use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants