This repository has been archived by the owner on Oct 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Component Testing Example: Vite + React | ||
|
||
This is an example **Vite + React** project with Cypress component testing. | ||
|
||
- `yarn` to install the dependencies | ||
- `npx cypress open-ct` to run interactively | ||
- `npx cypress run-ct` to run all tests headlessly | ||
|
||
The following was done to create this example: | ||
|
||
1. Initialize a baseline React project in the [vite-react](.) subdirectory | ||
1. `yarn create vite vite-react --template react` | ||
2. Commit [`f94faa4`](https://github.com/cypress-io/cypress-component-testing-examples/commit/f94faa4c0efb6591bfcec26a66a8bc093d02cb4e) | ||
2. Install project dependencies | ||
1. `cd vite-react` | ||
2. `yarn` | ||
3. Commit [`74b4844`](https://github.com/cypress-io/cypress-component-testing-examples/commit/74b4844a74d72298b349747ad2e7c6723bd71927) | ||
3. Refactor app into separate components, adjust global styles | ||
1. Move some code from [src/App.jsx](src/App.jsx) into [src/Counter.jsx](src/Counter.jsx) | ||
2. Move some styles from [src/App.css](src/App.css) into [src/Counter.css](src/Counter.css) | ||
3. Move global app styles into [src/index.css](src/index.css) | ||
4. Commit [`7e7f3b6`](https://github.com/cypress-io/cypress-component-testing-examples/commit/7e7f3b600fa992d9e476f08901b35a6363ba22af) | ||
4. Add Cypress component testing support with sample tests | ||
1. `yarn add -D cypress @cypress/react @cypress/vite-dev-server` | ||
2. Add [cypress.json](cypress.json) | ||
3. Add [cypress/plugins/index.js](cypress/plugins/index.js) | ||
4. Add [src/App.spec.ct.jsx](src/App.spec.ct.jsx), [src/Counter.spec.ct.jsx](src/Counter.spec.ct.jsx) | ||
5. `npx cypress open-ct` (Notice that the fonts don't inherit global app styles) | ||
6. Edit [cypress/support/index.js](cypress/support/index.js) to import global app styles, the Cypress test preview should update automatically | ||
7. Commit [`b1066e1`](https://github.com/cypress-io/cypress-component-testing-examples/commit/b1066e1ebf4f1a3b894dbd87b32d060294a726da) | ||
|
||
_This example was generated by [vite-react.sh](https://github.com/cypress-io/cypress-component-testing-examples/blob/scripts/vite-react.sh) on 2021-08-03. The original README follows._ | ||
|
||
--- | ||
|
||
|