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.

add jest-playwright.config.cjs to utils.ts #214

@fschoenfeldt

Description

@fschoenfeldt

Describe the bug
If my main program is a "module" inside package.json, I have to rename the config file to jest-playwright.config.cjs to use module.exports (CommonJS export way). That way, the configuration gets ignored and the default is used.

I changed the code inside the compiled utils.js to use my CommonJS configuration:

exports.readConfig = async (rootDir = process.cwd()) => {
    const hasCustomConfigPath = !!process.env.JEST_PLAYWRIGHT_CONFIG;
    const configPath = process.env.JEST_PLAYWRIGHT_CONFIG || 'jest-playwright.config.cjs';

Additional context
Maybe this isn't quite a bug, more like a feature request but can we add the cjs way to the configuration file importer parser thingy? So it either uses js or cjs?

Info
I was able to work around this by just passing JEST_PLAYWRIGHT_CONFIG=jest-playwright.config.cjs jest, now it works without changing the compiled jest-playwright-preset module.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions