Skip to content

Conversation

cacieprins
Copy link
Contributor

  • Closes

Additional details

  • Builds to CJS, since it is executed via node script and imported by @packages/server
  • Prepared to build to ESM in the future
  • Unwrapped some promises
  • Minor type annotations

This is in preparation for setting up vitest, so we can properly test the conditional logic for enabling or disabling stderr filtering.

Steps to test

How has the user experience changed?

PR Tasks

@cacieprins cacieprins marked this pull request as draft September 3, 2025 18:06
@jennifer-shehane jennifer-shehane marked this pull request as ready for review September 3, 2025 18:56
cursor[bot]

This comment was marked as outdated.

- **ES Modules**: Alternative build for modern Node.js applications
- **Output**: Compiled JavaScript in `dist/cjs/`, and a binary in `dist/Cypress`.

## Building
Copy link
Member

Choose a reason for hiding this comment

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

@cacieprins Should this link to the BUILD.md? Or are those instructions no longer needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Redundant - I'll remove build.md

Comment on lines +37 to +38
# Install/build Electron binary for current platform
./bin/cypress-electron --install
Copy link
Member

Choose a reason for hiding this comment

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

Where are these commands actually defined? Is it in the code somewhere to reference so these instructions don't go out of date?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The cli() fn in lib/electron.ts is what parses out the commands. I'd really like to use something like commander for our cli tools so it's more obvious, but it's pretty simple to trace from bin/cypress-electron to lib/electron.ts#cli. I'll add some docs.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@jennifer-shehane
Copy link
Member

@cacieprins Something about this PR is still failing

Copy link
Contributor

@AtofStryker AtofStryker left a comment

Choose a reason for hiding this comment

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

might be good to run the esm compile with a --noEmit just so we know there aren't regressions in this package as people add to it (though that's likely seldom).

Weird we have almost no tests. Might have some dead code as well because some of the functions from the main entry I can't find in the build.ts or the server.

debugElectron('dest path %s', dest)

try {
await fs.stat(appPath)
Copy link
Contributor

Choose a reason for hiding this comment

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

previously this was access. I am guessing we mostly just care for existence and this is fine and actually more appropriate

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, access is the right thing - the debug had me mixed up (and that fs-extra's remove fails silently if the fd does not exist).

return _install.check()
}

export function install (...args: Parameters<typeof _install.packageAndExit>) {
Copy link
Contributor

Choose a reason for hiding this comment

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

dumb question, but where exactly is this used? I'm guessing it's a part of the CLI but I can't find the invocation. That would mean the process.exit() cursor is complaining about is erroneous

Copy link
Contributor

Choose a reason for hiding this comment

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

hence the help command, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

But that uses installIfNeeded. I'm thinking this is dead code because it's not used in the build.ts script.

Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't need to be addressed in this PR. Mostly curious if this function is even used

Copy link
Contributor Author

Choose a reason for hiding this comment

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

post-install runs yarn workspace @packages/electron build-binary, which execs node ./bin/cypress-electron --install, which runs this fn. This is also how our tests launch cypress when invoked via scripts/cypress.js

cursor[bot]

This comment was marked as outdated.

@AtofStryker AtofStryker self-requested a review September 5, 2025 16:29
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Copy link

cypress bot commented Sep 5, 2025

cypress    Run #65322

Run Properties:  status check passed Passed #65322  •  git commit dab7c08d10: Update packages/electron/lib/electron.ts
Project cypress
Branch Review migrate-electron-lib-ts
Run status status check passed Passed #65322
Run duration 19m 28s
Commit git commit dab7c08d10: Update packages/electron/lib/electron.ts
Committer Cacie Prins
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 11
Tests that did not run due to a developer annotating a test with .skip  Pending 1102
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 26661
View all changes introduced in this branch ↗︎
UI Coverage  45.27%
  Untested elements 186  
  Tested elements 158  
Accessibility  97.71%
  Failed rules  4 critical   8 serious   2 moderate   2 minor
  Failed elements 110  

cursor[bot]

This comment was marked as outdated.

Copy link
Contributor

@AtofStryker AtofStryker left a comment

Choose a reason for hiding this comment

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

Changes look good

Co-authored-by: Bill Glesias <bglesias@gmail.com>
@cacieprins cacieprins merged commit 9ebddda into develop Sep 8, 2025
89 of 91 checks passed
@cacieprins cacieprins deleted the migrate-electron-lib-ts branch September 8, 2025 14:15
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Sep 9, 2025

Released in 15.2.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v15.2.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Sep 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants