* dependency: upgrades electron from 25 to 26 * bump cache run ci * fix docker img names * ref electron upgrade branch * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * debug * debug * debug * update search string for resize observer error swallow * debug * update integrity check * update electron readme with upgrade troubleshooting section * point to new publish binary workflow branch for electron 27 * update electron readme with locations of chromium & node versions for a given electron version * update node versions and docker image refs * update electron version to 27.1.3 * fix db nativeBinding arg * chore: updating v8 snapshot cache * install setuptools on mac when updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * run workflows on this branch run ci * require addon directly and pass to better-sqlite3 init; debug * rm debug * try loading better-sqlite with a more dynamic filename * bump electron version * bump electron version * bump electron version -- run ci * bump electron version -- run ci * bump electron version -- run ci * bump electron version -- run ci * bump electron version -- run ci * add a step to update workflows.yml to electron upgrade process * reduce retry limit on issue 1244 test to prevent circle from thinking tests have hanged * target main branch of binary publish workflow? run ci * Update .node-version -- run ci * Update CHANGELOG.md * Update module_api_spec.ts * point publish binary back to electron upgrade branch * Adds some logging re: cachedDataVersion * use precise electron version for better-sqlite3 for centos7 * Update CHANGELOG.md * chore: fix issue with bytenode (#28568) * fix jsc for 27 -- run ci * Update smoke.js * fix build * update electron upgrade steps * Update packages/electron/README.md Co-authored-by: Mike McCready <66998419+MikeMcC399@users.noreply.github.com> * Update cli/CHANGELOG.md Co-authored-by: Mike McCready <66998419+MikeMcC399@users.noreply.github.com> * fix DebugEmptyStates component test * try to fix downstream build -- run ci (#28649) Co-authored-by: Cacie Prins <cacieprins@users.noreply.github.com> * point to consolidated binary publish branch * revert webpack-preprocessor-awesome-typescript-loader update * revert certain system tests * increase padding for module api system test duration window * account for differing screenshot sizes * screenshot size differs locally vs ci * update protocol snapshots * Update after-pack-hook.js * fix flaky slideshow * correct the chromium version in changelog * use 18.17.1 internal images * workflow filters * fix trailing checkbox in electron readme * add solution to crashing better-sqlite3 in electron readme * Update packages/electron/README.md Co-authored-by: Bill Glesias <bglesias@gmail.com> * Update scripts/after-pack-hook.js Co-authored-by: Ryan Manuel <ryanm@cypress.io> * Update scripts/after-pack-hook.js Co-authored-by: Ryan Manuel <ryanm@cypress.io> * Update scripts/after-pack-hook.js Co-authored-by: Ryan Manuel <ryanm@cypress.io> * add branch to setup_should_persist_artifacts * debug app e2e test * bump cache * upgrade browsers-internal to chrome 121 * revert to chrome 118 images * bump cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * chore: updating v8 snapshot cache * bump cache --------- Co-authored-by: cypress-bot[bot] <+cypress-bot[bot]@users.noreply.github.com> Co-authored-by: Ryan Manuel <ryanm@cypress.io> Co-authored-by: Mike McCready <66998419+MikeMcC399@users.noreply.github.com> Co-authored-by: Bill Glesias <bglesias@gmail.com>
@packages/electron
This is the lib responsible for installing + building Electron. This enables us to develop with the Electron shell that will match how the final compiled Cypress binary looks 1:1.
It does this by using symlinks while in development.
Building
yarn workspace @packages/electron build
Note: this just installs Electron binary for your OS specific platform
Testing
yarn workspace @packages/electron test
yarn workspace @packages/electron test-debug
yarn workspace @packages/electron test-watch
Upgrading Electron
The version of electron that is bundled with Cypress should be kept as up-to-date as possible with the stable Electron releases. Many users expect the bundled Chromium and Node.js to be relatively recent. Also, historically, it has been extremely difficult to upgrade over multiple major versions of Electron at once, because of all the breaking changes in Electron and Node.js that impact Cypress.
Upgrading electron involves more than just bumping this package's package.json. Here are additional tasks to check off when upgrading Electron:
-
Write accurate changelog items. The "User-facing changelog" for an Electron upgrade should mention the new Node.js and Chromium versions bundled. If this is a patch version of
electron, a changelog entry might not be needed.- For example:
- Upgraded
electronfrom21.0.0to25.8.4. - Upgraded bundled Node.js version from
16.16.0to18.15.0. - Upgraded bundled Chromium version from
106.0.5249.51to114.0.5735.289.
- Upgraded
- For example:
-
Determine if the Electron upgrade is a breaking change. Electron upgrades constitute "breaking changes" in Cypress if:
- the major version number of Node.js changes, since users rely on the bundled Node.js to load plugins and
.jsfixtures, or - there are changes to Electron that require new shared libraries to be installed on Linux, breaking existing CI setups, or
- there is some other change that would break existing usage of Cypress (for example, a Web API feature being removed/added to the bundled Chromium)
- the major version number of Node.js changes, since users rely on the bundled Node.js to load plugins and
-
Create and publish Docker
base-internalandbrowsers-internalfamily images matching the Node.js and Chromium versions in Electron. These images live inside thecypress-docker-imagesrepository. Thebrowsers-internalimage will be used inside our CI pipelines. Thebase-internalimage will be used by thebrowsers-internalimage and possibly other system images (described below). The Chromium version can be determined from the DEPS file in Electron's repository on the correct tag. The Node version can be determined from the Electron Releases page. For general use of Cypress in Docker, we encourage the use of the Cypress Docker Factory. This works great for using Cypress as an end user, but doesn't fully suit the needs for developing Cypress, as we require:- The installation of packages, such as
curl,xauth, andbuild-essential/makeneeded for ourcirclecijobs/pipelines. - Specific images targeted to test Cypress on various node versions and distributions of linux, such as different versions of
ubuntu.
These images are currently created on an 'as-needed' basis and are published manually to the cypress docker repository. When creating these images, make sure:
- The browsers-internal image contains the latest version of Firefox and Edge.
- The Ubuntu images in base-internal are updated to be used in the system binary tests if any of the following are true for the images used inside the system binary tests:
- The last two major Ubuntu LTS Releases are out-of-date.
- The NodeJS version is not the active LTS.
- The installation of packages, such as
-
Update
workflows.yml- Ensure it references the new
base-internalandbrowsers-internalDocker images - Ensure the new Electron version is used as a build target in the
Build better-sqlite3 for CentOS 7step
- Ensure it references the new
-
Ensure that a matching Node.js version is enforced in the monorepo for local development and CI. When Electron is upgraded, oftentimes, the bundled Node.js version that comes with Electron is updated as well. Because all unit and integration tests run in normal Node.js (not Electron's Node.js), it's important for this Node.js version to be synced with the monorepo. There are a few places where this needs to be done:
/.node-version- used bynvmand other Node version managers@types/nodeused throughout the monorepo to determine compatible node types. The major version of this package must reflect the node version set in/.node-version.- github workflows - used for repository templates, vulnerability detection, and V8 snapshots. If the node version for Snyk needs to be updated, then the required pull request check into
developmust also be updated. A repository administrator will need to accomplish this. /package.json- updateenginesdocker-compose.yml- update Docker image to the new matchingbrowsersimage/system-tests/test-binary/*- update binary system tests to use the newly published Ubuntu and Node images mentioned above, if applicable/.circleci/config.yml- Update the Docker
images to the new matchingbrowsersimage. - Update the
xcodeversion to one with the same major Node.js version bundled. There is usually not an exact match, this is ok as long as the major version number as the same.
- Update the Docker
- Do a global search for the old Node.js version to identify any new areas that may need updating/unification, and update those locations (and this document!)
-
Update
cypress-publish-binaryFor binary publishing, make sure theelectronversion that we updated in/package.jsonmatches theelectronversion inside the publish binary project. This is to make sure add-on tests inside the publish-binary repository work locally, but are not required to install the correct version ofelectronin CI when publishing the binary. Ensure theelectrontarget in this project's.circleciconfiguration is updated as well. Set the Remove this before merging, and ensure that branch is merged as well.- Create a new branch in
cypress-publish-binary - Update
electronversion inpackage.json - Update the target
electronversion in the circle configuration - Update the docker image to the new browsers-internal image made in the previous step
- Temporarily update the circle configuration to allow
cypressto run against the branch - Temporarily set target
cypress-publish-binarybranch as abranchproperty on the request body in ../../scripts/binary/trigger-publish-binary-pipeline.js script, so that you can test against this branch from the electron upgrade branch
- Create a new branch in
-
Manually smoke test
cypress open. Upgrading Electron can break thedesktop-guiin unexpected ways. Since testing in this area is weak, double-check that things like launchingcypress open, signing into Cypress Cloud, and launching Electron tests still work. -
Manually smoke test
cypress runin record mode Upgrading Electron can causebetter-sqlite3to SIGSEGV the Electron process. -
Fix failing tests. Usually, these are due to breaking changes in either Node.js or Electron. Check the changelogs of both to find relevant changes.
-
If needed, update the V8 Snapshot Cache by running the GitHub workflow. Make sure to use the branch that contains the electron updates to populate the
'workflow from'and'branch to update'arguments. Select'Generate from scratch'and'commit directly to branch'. This will usually take 6-8 hours to complete and is best to not be actively developing on the branch when this workflow runs.
Common Upgrade Issues
Integrity Check Failures
Solution: Update the string representation of fs.readFileSync in scripts/binary/binary-integrity-check-source.js to match the string generated by the new version of electron. Create a throw-away script and simply console.log(fs.readFileSync.toString()), and execute it with Electron rather than Node.
ResizeObserver errors in Component Test
Solution: This error is benign. From time to time, the error message we match against in order to swallow the error changes. Update the necessary support files with the new error message.
Electron crashes immediately after initializing the Protocol database
Solution: This is often due to a mismatched prebuild of better-sqlite3. Ensure your repository is clear of untracked files with git clean -xfd, and run yarn again. If the issue persists, ensure you are running the latest version of your operating system. Electron prebuilds key to darwin/linux/windows, and do not differentiate between versions of the same.