-
Notifications
You must be signed in to change notification settings - Fork 359
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
Replace component test with React and Vite 4 #748
Replace component test with React and Vite 4 #748
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
76b7d6b
to
020cd0d
Compare
020cd0d
to
f66b7fd
Compare
This PR also mitigates 2 critical vulnerabilities in the current examples/component-tests as reported by dependabot and |
use documented example from https://docs.cypress.io/guides/component-testing/ with vite 4
f66b7fd
to
fad7315
Compare
Can you clarify the last line above? I didn't see a Add npm test for cypress run --component to examples/component-tests/package.json. |
|
cd examples/component-tests
npm ci added 264 packages, and audited 265 packages in 5s 43 packages are looking for funding found 0 vulnerabilities npm test
|
|
Ah, thank you. I misunderstood. |
Successful merge logged in job 4118815542. |
The description I provided was confusing, because I linked to examples/component-tests/package.json, which was unchanged at the time when you were reviewing the PR. Sorry for that! It is looking good in the master branch now, so we are quite close to completion of example updates! |
🎉 This PR is included in version 5.0.9 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This PR resolves issue #702 "Component test fails with Node.js 18 on Windows 11".
Current component-tests
The current outdated examples/component-tests demonstrates Cypress component testing with a React App configuration. It however does not run on Microsoft Windows with the Node.js LTS version (18) and it uses some component testing beta materials from prior to the release of Cypress v10, making it difficult to understand.
Replacement component-tests
This PR replaces the previous React App example with an up-to-date example built according to the Cypress documentation Guides > Cypress Component Testing > React Component Testing > React Quickstart. This uses Vite 4 to create the app, which is now supported by Cypress in version 12.4.0.
The following steps were taken:
Delete the existing examples/component-tests directory. Run the vite setup and install Cypress:
Continue with Configuration Component Testing to create
Stepper.jsx
andStepper.cy.jsx
:Create the file examples/component-tests/src/components/Stepper.jsx with contents as instructed.
In Cypress test app use "Create from component" from Stepper.jsx.
Modify the created test examples/component-tests/src/components/Stepper.cy.jsx as instructed by adding each of the suggested tests.
Add
npm test
forcypress run --component
to examples/component-tests/package.json.