Cypress Realworld App
A payment application to demonstrate real-world usage of Cypress testing methods, patterns, and workflows.
Install / Use
npx skills add cypress-io/cypress-realworld-appInstalls into whichever agent you are using.
README
💬 Note from maintainers
This application is purely for demonstration and educational purposes. Its setup and configuration resemble typical real-world applications, but it's not a full-fledged production system. Use this app to learn, experiment, tinker, and practice application testing with Cypress.
Happy Testing!
Features
🛠 Built with [React][reactjs], [XState][xstate], [Express][express], [lowdb][lowdb], [Material-UI][material-ui] and [TypeScript][typescript] ⚡️ Zero database dependencies 🚀 Full-stack [Express][express]/[React][reactjs] application with real-world features and tests 👮♂️ Local Authentication 🔥 Database Seeding with End-to-end Tests 💻 CI/CD + [Cypress Cloud][cypresscloud]
Getting Started
The Cypress Real-World App (RWA) is a full-stack Express/React application backed by a local JSON database ([lowdb]).
The app is bundled with example data (data/database.json) that contains everything you need to start using the app and run tests out-of-the-box.
🚩 Note
You can login to the app with any of the example app users. The default password for all users is
s3cret. Example users can be seen by runningyarn list:dev:users.
Prerequisites
This project requires Node.js to be installed on your machine. Refer to the .node-version file for the exact version.
Yarn Classic is also required. Once you have Node.js installed, execute the following to install the npm module yarn (Classic - version 1) globally.
npm install yarn@1 -g
If you have Node.js' experimental Corepack feature enabled,
then you should skip the step npm install yarn@1 -g to install Yarn Classic globally.
The RWA project is locally configured for Corepack to use Yarn Classic (version 1).
Yarn Modern
This project is not compatible with Yarn Modern (version 2 and later).
Installation
To clone the repo to your local system and install dependencies, execute the following commands:
git clone https://github.com/cypress-io/cypress-realworld-app
cd cypress-realworld-app
yarn
Mac users with M-series chips will need to prepend PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true.
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true yarn install
Run the app
yarn dev
🚩 Note
The app will run on port
3000(frontend) and3001(API backend) by default. Please make sure there are no other applications or services running on both ports. If you want to change the default ports, you can do so by modifyingPORTandVITE_BACKEND_PORTvariables in.envfile. However, make sure the modified port numbers in.envare not committed into Git since the CI environments still expect the application to run on the default ports.
Start Cypress
yarn cypress:open
🚩 Note
If you have changed the default ports, then you need to update Cypress configuration file (
cypress.config.ts) locally. There are three properties that you need to update incypress.config.ts:e2e.baseUrl,expose.apiUrl, andexpose.codeCoverage.url. The port number ine2e.baseUrlcorresponds toPORTvariable in.envfile. Similarly, the port number inexpose.apiUrlandexpose.codeCoverage.urlcorrespond toVITE_BACKEND_PORT. For example, if you have changedPORTto13000andVITE_BACKEND_PORTto13001in.envfile, then yourcypress.config.tsshould look similar to the following snippet:{ expose: { apiUrl: "http://localhost:13001", codeCoverage: { url: "http://localhost:13001/__coverage__" }, }, e2e: { baseUrl: "http://localhost:13000" } }Avoid committing the modified
cypress.config.tsinto Git since the CI environments still expect the application to be run on default ports.
Tests
| Type | Location |
| --------- | ---------------------------------------- |
| api | cypress/tests/api |
| ui | cypress/tests/ui |
| component | src/(next to component) |
| unit | src/__tests__ |
Database
-
The local JSON database is located in data/database.json and is managed with [lowdb].
-
The database is reseeded each time the application is started (via
yarn dev). Database seeding is done in between each Cypress End-to-End test. -
Updates via the React frontend are sent to the [Express][express] server and handled by a set of database utilities
-
Generate a new database using
yarn db:seed. -
An empty database seed is provided along with a script (
yarn start:empty) to view the application without data.
Additional NPM Scripts
| Script | Description | | -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | dev | Starts backend in watch mode and frontend | | dev:coverage | Starts backend in watch mode and frontend with instrumented code coverage enabled | | dev:auth0 | Starts backend in watch mode and frontend; Uses Auth0 for Authentication > Read Guide | | dev:okta | Starts backend in watch mode and frontend; Uses Okta for Authentication > Read Guide | | dev:cognito | Starts backend in watch mode and frontend; Uses Cognito for Authentication > Read Guide | | dev:google | Starts backend in watch mode and frontend; Uses Google for Authentication > Read Guide | | start | Starts backend and frontend | | types | Validates types | | db:seed | Generates fresh database seeds for json files in /data | | start:empty | Starts backend, frontend and Cypress with empty database seed | | tsnode | Customized ts-node command to get around react-scripts restrictions | | list:dev:users | Provides id and username for users in the dev database |
For a complete list of scripts see package.json
Code Coverage Report
The Cypress Real-World App uses the @cypress/code-coverage plugin to generate code coverage reports for the app frontend and backend.
To generate a code coverage report:
- Start the development server with coverage enabled by running
yarn dev:coverage. - Run
yarn cypress:run --env coverage=trueand wait for the test run to complete. - Once the test run is complete, you can view the report at
coverage/index.html.
3rd Party Authenticatio
Related Skills
node-connect
385.5kDiagnose OpenClaw Android, iOS, or macOS node pairing, QR/setup code, route, auth, and connection failures.
Writing Hookify Rules
140.7kThis skill should be used when the user asks to "create a hookify rule", "write a hook rule", "configure hookify", "add a hookify rule", or needs guidance on hookify rule syntax and patterns.
Agent Development
140.7kThis skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or…
Command Development
140.7kThis skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs gu…
