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

chore: more through system tests for react + bundle combinations #22329

Closed
wants to merge 9 commits into from

Conversation

lmiller1990
Copy link
Contributor

@lmiller1990 lmiller1990 commented Jun 15, 2022

User facing changelog

N/A

Additional details

Review Notes

102 files! Scary - well, not really. I committed the files in an easy-to-review way.

  1. 4fae75d - move "basic" specs directory from npm/react to project-fixtures/npm-react. No change here, just moving things around.
  2. c999048 added new test projects (npm-react-vite, npm-react-webpack). Basic config.
  3. 7b5008f added new system test to run npm-react against Vite and Webpack

Summary

As noted in. #21965 (comment), in b326693, a bunch of tests got straight up deleted, and npm/react move from Vite to Webpack. The majority of the specs were duplicates, but we should keep some, as well as start moving more npm/react tests to system-tests, which lets us easily run them against multiple combinations of webpack/vite/react versions.

During #21965, the main thing we lost was coverage of webpack + React - the most popular way to bundle and serve React apps.

In this PR, I moved a number of specs from npm/react/component/basic to system-tests/project-fixtures/npm-react. We now run these specs system-tests in:

  • system-tests/project-fixtures/npm-react-webpack
  • system-tests/project-fixtures/npm-react-vite

To verify some of the more complex examples (things like webpack/babel, CSS modules, stub/spy on component methods) work properly for both Vite and Webpack.

Steps to test

Just observe CI is passing!

How has the user experience changed?

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) yes, 10.1.1
  • [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 Jun 15, 2022

Thanks for taking the time to open a PR!

@lmiller1990 lmiller1990 changed the title chore: more through system tests for CT/React chore: more through system tests for react + bundle combinations Jun 15, 2022
@lmiller1990 lmiller1990 marked this pull request as ready for review June 15, 2022 10:03
@lmiller1990 lmiller1990 requested review from a team as code owners June 15, 2022 10:03
@lmiller1990 lmiller1990 removed request for a team June 15, 2022 10:04
@cypress
Copy link

cypress bot commented Jun 15, 2022



Test summary

37729 0 456 0Flakiness 11


Run details

Project cypress
Status Passed
Commit adc5911
Started Jul 19, 2022 11:31 PM
Ended Jul 20, 2022 12:00 AM
Duration 28:42 💡
OS Linux Debian - 10.11
Browser Multiple

View run in Cypress Dashboard ➡️


Flakiness

actions/click.cy.js Flakiness
1 ... > scroll-behavior > can scroll to and click elements in html with scroll-behavior: smooth
xhr.cy.js Flakiness
1 ... > logs request + response headers
2 ... > logs Method, Status, URL, and XHR
3 ... > logs response
4 ... > logs Method, Status, URL, and XHR
This comment includes only the first 5 flaky tests. See all 11 flaky tests in the Cypress Dashboard.

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
Contributor

@ZachJW34 ZachJW34 left a comment

Choose a reason for hiding this comment

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

I think we should choose a different name for the system-test project/project-fixture. What does the npm- prefix mean? That it is testing react with external deps? Something like react-advanced would make more sense to me.

Only blocking comment is the react resolve issue.

'**/__snapshots__/*',
'**/__image_snapshots__/*',
'examples/**/*',
// due to how we handle system-tests, tests with hooks
Copy link
Contributor

Choose a reason for hiding this comment

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

We can fix this with a change to webpackConfig.resolve i.e.

webpackConfig: {
    ...webpackConfig,
    resolve: {
      alias: {
        react: require.resolve('react'),
        'react-dom': require.resolve('react-dom'),
      },
    },
  },

I know it's a hack for our system-tests, but having the hack gives us more coverage and I would feel better knowing the system test is actually using the correct version of react. I know we can do similar hack for vite to resolve from the project rather than our node_modules.

Also, I noticed the counter-hooks.cy.jsx has a compile error, it should be importing the component with the extension (same with input-accumulator.cy.jsx).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll try the alias.resolve, nice idea.

As for the jsx extension, we actually don't need it here since we've got

resolve: {
    extensions: ['.js', '.ts', '.jsx', '.tsx'],

In the webpack.config.js.

@@ -0,0 +1,31 @@
{
"devDependencies": {
"@babel/core": "7.4.5",
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like we can remove a decent amount of these deps, namely:

"@bahmutov/cy-api": "1.4.2",
"@bahmutov/cy-rollup": "2.0.0",
"@cypress/code-coverage": "3.9.4",
"babel-plugin-istanbul": "6.0.0",
"babel-plugin-module-resolver": "4.0.0",
"cypress-plugin-snapshots": "1.4.4",
"module-resolver": "1.0.0",

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, nice.

@@ -295,6 +295,7 @@ export async function scaffoldCommonNodeModules () {
'lodash',
'proxyquire',
'react',
'react-dom',
Copy link
Contributor

Choose a reason for hiding this comment

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

If we use resolve/alias to resolve the proper react/react-dom packages, do we need this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think if we have react here, we should include react-dom too - only caching one could lead to pretty confusing and hard to debug errors. Or, we should remove both. I saw react was here by itself, so I added react-dom.

Copy link
Contributor

Choose a reason for hiding this comment

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

For consistency that makes sense. Ideally I think we should remove both but I imagine doing so would cause other tests to fail

@jennifer-shehane jennifer-shehane removed their request for review June 24, 2022 15:34
@ZachJW34 ZachJW34 requested a review from tgriesser June 29, 2022 13:57
@lmiller1990 lmiller1990 removed the request for review from tgriesser July 19, 2022 22:26
@lmiller1990
Copy link
Contributor Author

Now #22876 is landing, I'm thinking the infra set up there is probably a better way to incrementally add tests to many projects at once. Gonna close this in favor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move CT Example tests to System tests
2 participants