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.

playwright-firefox and friends always installed #49

@tkrotoff

Description

@tkrotoff

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

$ node --version
v12.14.1
$ npm --version
6.13.4
$ npm ls playwright-firefox
[email protected]
└─┬ [email protected]
  └── [email protected]
$ npm ls playwright-webkit
[email protected]
└─┬ [email protected]
  └── [email protected] 

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions