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

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

Closed
fschoenfeldt opened this issue Jul 12, 2020 · 1 comment · Fixed by #215
Closed

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

fschoenfeldt opened this issue Jul 12, 2020 · 1 comment · Fixed by #215
Labels
enhancement New feature or request

Comments

@fschoenfeldt
Copy link
Contributor

fschoenfeldt commented Jul 12, 2020

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.

@mmarkelov
Copy link
Member

@fschoenfeldt thanks for report. For me this is not a bug. You should use JEST_PLAYWRIGHT_CONFIG for this purpose. Also I think that I can make some checks to use jest-playwright.config.cjs if there is module inside package.json

@mmarkelov mmarkelov added the enhancement New feature or request label Jul 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants