mirror of
https://github.com/cypress-io/cypress.git
synced 2026-01-14 10:59:54 -06:00
* Remove useless code * Add code-coverage to reacr devDependencies * Remove react/support imports * Remove some useless code from @cypress/react * Cleanup vue * Make it works :) * Fix react errors * Fix next.js react example Co-authored-by: Lachlan Miller <lachlan.miller.1990@outlook.com> Co-authored-by: Barthélémy Ledoux <bart@cypress.io>
example: react-scripts
A typical project using
react-scriptswith components and matching component tests residing in the src folder.
Usage
- Make sure the root project has been built .
# in the root of the project
npm install
npm run build
- Run
npm installin this folder to symlink the@cypress/reactdependency.
# in this folder
npm install
- Start Cypress
npm run cy:open
# or just run headless tests
npm test
Notes
The spec src/Logo.cy-spec.js directly imports SVG into React spec file. The spec src/resources.cy-spec.js confirm that static resources like SVG and fonts load correctly.
Env files
React Scripts automatically loads .env files. The NODE_ENV is set to test when loading scripts, thus the .env.test files are combined and the final process.env contains an object with string values.
See the test in src/App.cy-spec.js and local .env files in this folder.

