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

feat: support "browser" config option #220

Merged
merged 3 commits into from
May 6, 2019

Conversation

aslushnikov
Copy link
Contributor

This patch adds a new option to jest-puppeteer.config.js - browser. The option might be either 'chromium' or 'firefox' (case-insensetive) and defaults to 'chromium'. Depending on this option, either puppeteer or puppeteer-firefox will be used to drive test execution.

Test plan

There's a unit test in the PR. Let me know if/how I should add an integration test.

Fixes #171

Copy link
Member

@gregberge gregberge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @aslushnikov! It is great, but we have to remove peer dependencies.

@@ -28,6 +27,7 @@ class PuppeteerEnvironment extends NodeEnvironment {

async setup() {
const config = await readConfig()
const puppeteer = await getPuppeteer(config)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need of await

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


let browser

export async function setup(jestConfig = {}) {
const config = await readConfig()
const puppeteer = await getPuppeteer(config)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need of await.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

packages/jest-environment-puppeteer/package.json Outdated Show resolved Hide resolved
@aslushnikov
Copy link
Contributor Author

@neoziro thanks for reviewing! I rebaselined atop of master and dropped the peer dependences. Is there anything else I should do?

Looking forward for this to be merged! :-)

@gidztech
Copy link
Contributor

Just to clarify, this would mean the end user will manually need to install puppeteer or puppeteer-firefox in their own project, depending on the configuration option they set. If that's the case, maybe we need a note in the README (high up) in case people complain that they get runtime errors from missing dependencies.

@aslushnikov
Copy link
Contributor Author

Just to clarify, this would mean the end user will manually need to install puppeteer or puppeteer-firefox in their own project, depending on the configuration option they set.

@gidztech this is already the case for Puppeteer. I added a small note to the jest-environment-puppeter readme.

return require('puppeteer-firefox')
default:
throw new Error(
`!!env variable JEST_PUPPETEER_BROWSER is given unsupported value: ${browser}`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this message is not good. I don't see any JEST_PUPPETEER_BROWSER variable elsewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@gregberge
Copy link
Member

@xiaoyuhen if you have time, I would be glad if you could test it. If it is OK for you, could you please tell me then I will merge and release a new version (also included your latest fix).

@xiaoyuhen
Copy link
Contributor

@neoziro

yeah, Will check before this Saturday.

@xiaoyuhen
Copy link
Contributor

xiaoyuhen commented May 3, 2019

Failed to download Firefox r2f959d575a3d61f5dda12e4e2dca1f46a92ab569!

Because of the Great Firewall of 🇨🇳, I can't download Firefox at home.

Chromium is ok because I can use the mirrors of Chromium. Firefox dont have any mirror on 🇨🇳

Maybe I need to update my VPN, the check may be delayed until this Sunday.

😢

@xiaoyuhen xiaoyuhen merged commit 85a1122 into argos-ci:master May 6, 2019
@xiaoyuhen
Copy link
Contributor

@neoziro I create a firefox example, it works great. I will take a PR after the new version released.

@aslushnikov Thanks for your great job!

@aslushnikov aslushnikov deleted the puppeteer-firefox branch May 6, 2019 05:59
@aslushnikov
Copy link
Contributor Author

Thanks @xiaoyuhen and @neoziro for your time!

@gziolo
Copy link

gziolo commented May 16, 2019

Just to clarify, this would mean the end user will manually need to install puppeteer or puppeteer-firefox in their own project, depending on the configuration option they set.

@gidztech this is already the case for Puppeteer. I added a small note to the jest-environment-puppeter readme.

I don't see any mention of Firefox or puppeteer-firefox in the current version of README file:
https://github.com/smooth-code/jest-puppeteer/blob/696f99d28a7c427aa0fca130bbc4f8dd2042e9c3/README.md

# for jest 22~23
npm install --save-dev [email protected] puppeteer jest
# for jest 24+
npm install --save-dev jest-puppeteer puppeteer jest

It would be great to clarify that it's also possible to do

npm install --save-dev jest-puppeteer puppeteer-firefox jest

if you opt in to use Firefox. I'm wondering whether this is something that could be handled in puppeteer npm package. As a consumer of jest-puppeteer I would love to be in a position where I don't need to juggle with Puppeteer related dependencies at all. It could even go further and puppeteer would install Chromium of Firefox only when I try to use one of them for the first time.

@gregberge
Copy link
Member

Could someone submit a PR to document it?

@rodoabad
Copy link

rodoabad commented Jun 8, 2019

This is great news guys!~

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 this pull request may close these issues.

Add support for Firefox thx to puppeteer-firefox
6 participants