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

fix: fix third party reporters and cy.origin calls in Cypress #24614

Conversation

ryanthemanuel
Copy link
Collaborator

@ryanthemanuel ryanthemanuel commented Nov 9, 2022

User facing changelog

Cypress will no longer crash when using a third party reporter like mochawesome.

Cypress will no longer crash when using the experimentalSessionAndOrigin flag.

Additional details

When cleaning up the binary due to the v8 snapshot work, there were a couple of dependencies that were removed that shouldn't have been.

In the case of third party mocha reporters, we do some swizzling at runtime with a hard coded version of mocha (mocha-7.0.1). In order to allow this to work properly, we need to leave mocha-7.0.1 in the binary.

In the case of the experimentalSessionAndOrigin flag, we have a dynamically loaded loader whose dependencies were not being flagged as something that shouldn't be removed. We will ensure that these dependencies are kept by wrapping this dependency in a require.resolve.

Steps to test

Run the binary with a third party reporter like mochaawesome

Run the binary with experimentalSessionAndOrigin turned on

How has the user experience changed?

The app no longer crashes in the above scenarios.

PR Tasks

  • Have tests been added/updated?
  • Has the original issue (or this PR, if no issue exists) been tagged with a release in ZenHub? (user-facing changes only)
  • [na] Has a PR for user-facing changes been opened in cypress-documentation?
  • [na] Have API changes been updated in the type definitions?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Nov 9, 2022

Thanks for taking the time to open a PR!

@ryanthemanuel ryanthemanuel marked this pull request as ready for review November 9, 2022 14:51
@@ -249,7 +249,7 @@ const preprocessor: WebpackPreprocessor = (options: PreprocessorOptions = {}): F
webpackOptions.module.rules.unshift({
test: /\.(js|ts|jsx|tsx)$/,
use: [{
loader: path.join(__dirname, 'lib/cross-origin-callback-loader'),
loader: require.resolve('@cypress/webpack-preprocessor/dist/lib/cross-origin-callback-loader.js'),
Copy link
Member

Choose a reason for hiding this comment

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

If we need to do require.resolve() within the NPM module, is there risk that custom webpack configuration will be problematic or is this only for snapshot resolution in the binary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is only for snapshot resolution in the binary.

Copy link
Member

Choose a reason for hiding this comment

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

& vite doesn't have issues because we don't ship with the binary? https://github.com/cypress-io/cypress/blob/develop/npm/vite-dev-server/src/resolveConfig.ts#L14

@@ -20,6 +20,7 @@
"watch": "rimraf dist && tsc --watch"
},
"dependencies": {
"@babel/parser": "7.13.0",
Copy link
Member

Choose a reason for hiding this comment

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

why does this need @babel/parser?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@cypress
Copy link

cypress bot commented Nov 9, 2022



Test summary

594 1 45 7Flakiness 5


Run details

Project cypress
Status Failed
Commit a77d4f0
Started Nov 9, 2022 9:34 PM
Ended Nov 9, 2022 9:50 PM
Duration 15:28 💡
OS Windows 10.0.17763
Browser Chrome 107

View run in Cypress Dashboard ➡️


Failures

cypress\e2e\specs.cy.ts Failed
1 ... > shows No Specs page with specPattern from config

Flakiness

cypress\e2e\top-nav-launchpad.cy.ts Flakiness
1 ... > global mode > shows "continue" button after login if project selected
cypress\e2e\migration.cy.ts Flakiness
1 Full migration flow for each project > completes journey for migration-e2e-component-default-with-types
cypress\e2e\scaffold-component-testing.cy.ts Flakiness
1 scaffolding component testing > vuecli4vue2 > scaffolds component testing for Vue CLI 4 w/ Vue 2 project
cypress\e2e\specs_list_latest_runs.cy.ts Flakiness
1 App/Cloud Integration - Latest runs and Average duration > when no runs are recorded > shows placeholders for all visible specs
2 App/Cloud Integration - Latest runs and Average duration > polling indicates new data > refreshes view to reflect new data

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

Copy link
Member

@emilyrohrbough emilyrohrbough left a comment

Choose a reason for hiding this comment

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

Binary changes seem to be working for the various scenarios I tried. 👍🏻

@ryanthemanuel ryanthemanuel deleted the ryanm/fix/improve-binary-cleanup-to-look-at-binary-rather-than-monorepo branch November 9, 2022 22:01
@ryanthemanuel ryanthemanuel restored the ryanm/fix/improve-binary-cleanup-to-look-at-binary-rather-than-monorepo branch November 9, 2022 22:03
@ryanthemanuel ryanthemanuel reopened this Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants