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

"useDocker: true" does not allow configuring puppeteer via jest-puppeteer.config.js #75

Open
mihkeleidast opened this issue Jun 1, 2020 · 6 comments

Comments

@mihkeleidast
Copy link
Contributor

Background

We've been battling with some text rendering differences on my local machine and in CI. We have jest-puppeteer-react configured so that it uses docker locally and does not use docker in CI (as it's already a docker environment).

We tried to configure puppeteer the following way - we added the --font-render-hinting=medium option to minimize the text rendering differences.

module.exports = {
    launch: {
        dumpio: true,
        headless: true,
        ignoreHTTPSErrors: true,
        args: ['--headless', '--disable-gpu', '--disable-dev-shm-usage', '--font-render-hinting=medium'],
    }
};

Bug description

the jest-puppeteer.config.js config is only used by jest-puppeteer if useDocker: false is specified in jest-puppeteer-react.config.js. To verify that, I logged the jest-puppeteer config to my console.

With useDocker: false:

{
  launch: {
    dumpio: true,
    headless: true,
    ignoreHTTPSErrors: true,
    args: [ '--headless', '--disable-gpu', '--disable-dev-shm-usage' ]
  },
  browser: 'chromium',
  browserContext: 'default',
  exitOnPageError: true
}

With useDocker: true:

{
  launch: {},
  browser: 'chromium',
  browserContext: 'default',
  exitOnPageError: true,
  connect: {
    browserWSEndpoint: 'ws://0.0.0.0:9222/devtools/browser/8d99e5a0-1f5c-4c26-ad92-3eb0afbcf68f'  }
}

Note that the launch object is empty when using docker.

Expected behavior

Puppeteer config should be loaded in regardless of the useDocker setting.

@mihkeleidast
Copy link
Contributor Author

Just thinking loud about the potential solutions. I found jest-puppeteer-docker library that could potentially be used instead of the Docker integration in this plugin. I'll try to make it work on my end at some point, maybe we could remove all the custom Docker code here and instead document how to configure these plugins together?

@doochik
Copy link
Contributor

doochik commented Jun 1, 2020

Few months ago I've tried to do the same. Now I think that there is no way to achieve same font rendering in docker and local chromium (docker and macOS in my case).

Integration with jest-puppeteer-docker will be useful anyway.

@rosczja
Copy link
Member

rosczja commented Jun 25, 2020

Have you tried to add this argument to the "dockerCommand" option in jest-puppeteer-react.config.js?

@mihkeleidast
Copy link
Contributor Author

I'm not sure how I can add puppeteer options to the docker image command?

I eventually forked this lib and made some changes to it. Ended up with the following config:

    dockerHost: dockerHost(),
    dockerImageName: 'zenika/alpine-chrome:80',
    dockerCommand: '--no-sandbox --remote-debugging-address=0.0.0.0 --remote-debugging-port=9222',
    port: 1111,
    jestPuppeteerConfig: {
        connect: isCi ? connectCi : undefined,
        launch: {
            dumpio: true,
            headless: true,
            ignoreHTTPSErrors: true,
            args: ['--headless', '--disable-gpu', '--disable-dev-shm-usage'],
        },
    },

Basically, I changed it so the lib always uses "it's own" jest-puppeteer config and allows adding props to it in jest-puppeteer-react.config.js (similar behavior for both use cases + less config files).

Either way, I'd like to discard my internal fork if there's a better solution in here.

@rosczja
Copy link
Member

rosczja commented Jun 25, 2020

I thought you wanted to add a Chrome argument, not a puppeteer option.

I like the idea of having one config file and adding a "jestPuppeteerConfig" section.

@SpawnAtis
Copy link

The related issue

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

Successfully merging a pull request may close this issue.

4 participants