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

playwright-firefox and friends always installed #49

Closed
tkrotoff opened this issue Feb 23, 2020 · 1 comment · Fixed by #51
Closed

playwright-firefox and friends always installed #49

tkrotoff opened this issue Feb 23, 2020 · 1 comment · Fixed by #51
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@tkrotoff
Copy link

tkrotoff commented Feb 23, 2020

playwright-firefox, playwright-chromium and playwright-webkit always get installed

$ node --version
v12.14.1
$ npm --version
6.13.4
$ npm ls playwright-firefox
my-app@1.0.0
└─┬ jest-playwright-preset@0.0.10
  └── playwright-firefox@0.11.1
$ npm ls playwright-webkit
my-app@1.0.0
└─┬ jest-playwright-preset@0.0.10
  └── playwright-webkit@0.11.1 

This is because they are declared as optionalDependencies: https://github.com/mmarkelov/jest-playwright/blob/v0.0.10/package.json#L48-L54

This generates inside package-lock.json:

"jest-playwright-preset": {
  "version": "0.0.10",
  "resolved": "https://registry.npmjs.org/jest-playwright-preset/-/jest-playwright-preset-0.0.10.tgz",
  "integrity": "sha512-iE7hO1v4UEvEpXXxF/7xLEnifsbceqd6UmDm82dACKakx7JAD9T3JdJkBX2j3HGOBlDYMdBeK5wdhfnWFQXDJA==",
  "dev": true,
  "requires": {
    "jest-dev-server": "^4.4.0",
    "playwright-chromium": ">=0.11.0",
    "playwright-core": ">=0.11.0",
    "playwright-firefox": ">=0.11.0",
    "playwright-webkit": ">=0.11.0"
  }
}

optionalDependencies does not work like you think: https://docs.npmjs.com/files/package.json#optionaldependencies

If a dependency can be used, but you would like npm to proceed if it cannot be found or fails to install, then you may put it in the optionalDependencies object.

optionalDependencies are like dependencies: always downloaded. the if it cannot be found does not seem to be respected. I know it sucks, this makes it pretty useless.

Problem is firefox, chromium and webkit are heavy downloads, specially for a CI (downloaded on each CI run).

Proposed solution: remove optionalDependencies and clearly states in the docs that the user should download either playwright (bundles the 3 browsers) or playwright-firefox or playwright-chromium or playwright-webkit (to be verified, this is my understanding). Maybe move playwright-core to devDependencies?

btw jest-puppeteer does not have any optionalDependencies: https://github.com/smooth-code/jest-puppeteer/blob/949027b1332e270fad78eda10fd1a92c56abe1b5/package.json

btw It's always nice to declare an empty dependencies: {} instead of omitting it: makes it clear when reading the package.json

@mxschmitt
Copy link
Member

Hey,

I've also experienced the issue, that even when I install only playwright-chromium on my actual repository also their friends get's installed by jest-playwright.

For me your described approach makes sense and should probably work.
PR is open, have to add docs now.

@mmarkelov mmarkelov added documentation Improvements or additions to documentation enhancement New feature or request labels Feb 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants