• Stars
    star
    5,145
  • Rank 7,674 (Top 0.2 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 4 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A payment application to demonstrate real-world usage of Cypress testing methods, patterns, and workflows.

Cypress Real World App Logo

Cypress Logo

A payment application to demonstrate real-world usage of Cypress testing methods, patterns, and workflows.

Cypress Real World App

💬 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, XState, Express, lowdb, Material-UI and TypeScript ⚡️ Zero database dependencies 🚀 Full-stack Express/React application with real-world features and tests 👮‍♂️ Local Authentication 🔥 Database Seeding with End-to-end Tests 💻 CI/CD + Cypress Cloud

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 running yarn 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@latest -g

If you have Node.js' experimental Corepack feature enabled, then you should skip the step npm install yarn@latest -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

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) and 3001 (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 modifying PORT and VITE_BACKEND_PORT variables in .env file. However, make sure the modified port numbers in .env are 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 in cypress.config.ts: e2e.baseUrl, env.apiUrl, and env.url. The port number in e2e.baseUrl corresponds to PORT variable in .env file. Similarly, the port number in env.apiUrl and env.url correspond to VITE_BACKEND_PORT. For example, if you have changed PORT to 13000 and VITE_BACKEND_PORT to 13001 in .env file, then your cypress.config.ts should look similar to the following snippet:

{
  env: {
    apiUrl: "http://localhost:13001",
    codeCoverage: {
      url: "http://localhost:13001/__coverage__"
    },
  },
  e2e: {
    baseUrl: "http://localhost:13000"
  }
}

Avoid committing the modified cypress.config.ts into 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 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:

  1. Start the development server with coverage enabled by running yarn dev:coverage.
  2. Run yarn cypress:run --env coverage=true and wait for the test run to complete.
  3. Once the test run is complete, you can view the report at coverage/index.html.

3rd Party Authentication Providers

Support for 3rd party authentication is available in the application to demonstrate the concepts on logging in with a 3rd party provider.

The app contains different entry points for each provider. There is a separate index file for each provider, and to use one, you must replace the current index.tsx file with the desired one. The following providers are supported:

Auth0

The Auth0 tests have been rewritten to take advantage of our cy.session and cy.origin commands.

Prerequisites include an Auth0 account and a Tenant configured for use with a SPA. Environment variables from Auth0 are to be placed in the .env. For more details see Auth0 Application Setup and Setting Auth0 app credentials in Cypress.

To start the application with Auth0, replace the current src/index.tsx file with the src/index.auth0.tsx file and start the application with yarn dev:auth0 and run Cypress with yarn cypress:open.

The only passing spec on this branch will be the auth0 spec; all others will fail. Please note that your test user will need to authorize your Auth0 app before the tests will pass.

Okta

A guide has been written with detail around adapting the RWA to use Okta and to explain the programmatic command used for Cypress tests.

Prerequisites include an Okta account and application configured for use with a SPA. Environment variables from Okta are to be placed in the .env.

To start the application with Okta, replace the current src/index.tsx file with the src/index.okta.tsx file and start the application with yarn dev:okta and run Cypress with yarn cypress:open.

The only passing spec on this branch will be the okta spec; all others will fail.

Amazon Cognito

A guide has been written with detail around adapting the RWA to use Amazon Cognito as the authentication solution and to explain the programmatic command used for Cypress tests.

Prerequisites include an Amazon Cognito account. Environment variables from Amazon Cognito are provided by the AWS Amplify CLI.

To start the application with Cognito, replace the current src/index.tsx file with the src/index.cognito.tsx file and start the application with yarn dev:cognito and run Cypress with yarn cypress:open.

The only passing spec on this branch will be the cognito spec; all others will fail.

Google

A guide has been written with detail around adapting the RWA to use Google as the authentication solution and to explain the programmatic command used for Cypress tests.

Prerequisites include an Google account. Environment variables from Google are to be placed in the .env.

To start the application with Google, replace the current src/index.tsx file with the src/index.google.tsx file and start the application with yarn dev:google and run Cypress with yarn cypress:open.

The only passing spec when run with yarn dev:google will be the google spec; all others will fail.

License

license

This project is licensed under the terms of the MIT license.

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Kevin Old

Amir Rustamzadeh

Brian Mann

Gleb Bahmutov

Ben Hong

David Khourshid

This project follows the all-contributors specification. Contributions of any kind welcome!!

More Repositories

1

cypress

Fast, easy and reliable testing for anything that runs in a browser.
JavaScript
46,071
star
2

cypress-example-recipes

Various recipes for testing common scenarios with Cypress
JavaScript
3,113
star
3

github-action

GitHub Action for running Cypress end-to-end & component tests
JavaScript
1,294
star
4

cypress-example-kitchensink

This is an example app used to showcase Cypress.io testing.
HTML
1,130
star
5

cypress-docker-images

Docker images with Cypress dependencies and browsers
Dockerfile
906
star
6

cypress-documentation

Cypress Documentation including Guides, API, Plugins, Examples, & FAQ.
TypeScript
827
star
7

eslint-plugin-cypress

An ESLint plugin for projects that use Cypress
JavaScript
692
star
8

cypress-react-unit-test

Unit test React components using Cypress
678
star
9

testing-workshop-cypress

End-to-end testing workshop with Cypress
JavaScript
474
star
10

code-coverage

Saves the code coverage collected during Cypress tests
JavaScript
411
star
11

cypress-vue-unit-test

A little helper to unit test Vue components in the Cypress.io E2E test runner
294
star
12

cypress-example-todomvc

The official TodoMVC tests written in Cypress.
JavaScript
237
star
13

cypress-and-jest-typescript-example

Example using Jest and Cypress with TypeScript in a single repo
TypeScript
231
star
14

cypress-chrome-recorder

Export Cypress Tests from Google Chrome DevTools' Recorder
TypeScript
223
star
15

cypress-skip-test

Simple commands to skip a test based on platform, browser or a url
JavaScript
178
star
16

circleci-orb

Install, cache and run Cypress.io tests on CircleCI with minimal configuration.
156
star
17

cypress-recorder-extension

JavaScript
147
star
18

cypress-xpath

Adds XPath command to Cypress test runner
JavaScript
146
star
19

cypress-example-docker-compose

Example running Cypress tests against Apache server via docker-compose
JavaScript
142
star
20

cypress-fiddle

Quickly generates Cypress tests from HTML and JS code
JavaScript
138
star
21

cypress-grep

Filter tests using substring
JavaScript
138
star
22

cypress-example-docker-circle

Cypress + Docker + CircleCI = ❤️
JavaScript
124
star
23

cypress-example-api-testing

[ARCHIVED] Cypress E2E runner can also test Rest and other APIs
JavaScript
120
star
24

snapshot

Adds value / object / DOM element snapshot testing support to Cypress test runner
JavaScript
115
star
25

cypress-example-conduit-app

[ARCHIVED] Conduit example blogging app.
JavaScript
108
star
26

cypress-webpack-preprocessor

Cypress preprocessor for bundling JavaScript via webpack
93
star
27

add-cypress-custom-command-in-typescript

Testing how new Cypress commands are added in TypeScript
TypeScript
88
star
28

netlify-plugin-cypress

Runs Cypress end-to-end tests after Netlify builds the site but before it is deployed
JavaScript
88
star
29

chromium-downloads

A website that helps users to find and download archived Chromium versions.
JavaScript
83
star
30

cypress-realworld-testing

Next.js project for learn.cypress.io
MDX
72
star
31

schema-tools

Validate, sanitize and document JSON schemas
TypeScript
72
star
32

cypress-realworld-testing-course-app

TypeScript
65
star
33

instrument-cra

Little module for CRA applications to instrument code without ejecting react-scripts
JavaScript
63
star
34

cypress-component-testing-apps

TypeScript
59
star
35

cypress-test-tiny

Tiny Cypress E2E test case
JavaScript
52
star
36

cypress-example-todomvc-redux

Example TodoMVC application with full code coverage
JavaScript
51
star
37

cypress-test-nested-projects

[ARCHIVED] Tests Cypress running tests in subfolders
JavaScript
48
star
38

xvfb

Easily start and stop an X Virtual Frame Buffer from your node apps
JavaScript
40
star
39

cypress-tutorial-build-todo

Step by step code for the Cypress tutorial in which we build and test a todo app
JavaScript
39
star
40

cypress-tutorial-build-todo-starter

Starter project for the Cypress tutorial in which we build and test a todo app
CSS
38
star
41

cypress-cli

CLI for Cypress.io Desktop App
CoffeeScript
38
star
42

cypress-component-testing-examples

Cypress component examples
JavaScript
33
star
43

birdboard

Example Twitter client web app shown in Cypress in a Nutshell webcast.
JavaScript
33
star
44

cypress-example-docker-circle-workflows

Cypress + Docker + CircleCI Workflows = ❤️
JavaScript
29
star
45

cypress-example-circleci-orb

Demo of using the Cypress CircleCI Orb
JavaScript
28
star
46

cypress-test-example-repos

[ARCHIVED] Tests new version of Cypress against multiple projects
JavaScript
27
star
47

cypress-workshop-ci

A workshop that teaches you how to run Cypress on major CI providers
CSS
27
star
48

angular-pizza-creator

Example Angular Pizza ordering app
TypeScript
26
star
49

cypress-realworld-testing-blog

A Next.js Blog for the Real World Testing with Cypress Curriculum
JavaScript
24
star
50

cypress-browserify-preprocessor

Cypress preprocessor for bundling JavaScript via browserify
JavaScript
23
star
51

cypress-example-docker-compose-included

Cypress example with docker-compose and cypress/included image
JavaScript
20
star
52

cypress-electron-plugin

Cypress plugin for testing Electron applications
JavaScript
18
star
53

commit-info

Collects Git commit info using git
JavaScript
17
star
54

cypress-component-examples

Cypress configured with various frameworks and dev servers
JavaScript
17
star
55

cypress-heroes

Cypress Heroes Demo App
TypeScript
17
star
56

cypress-example-reporters

[ARCHIVED] Example showing multiple test reports merged into a single Mochawesome report
JavaScript
17
star
57

cra-template-cypress

The base Cypress template for Create React App
JavaScript
17
star
58

cypress-mock-ssr

Node.js Mock SSR Middleware and Cypress Commands
JavaScript
16
star
59

react-tooltip

A tooltip component for React apps
JavaScript
16
star
60

cra-template-cypress-typescript

The base Cypress + TypeScript template for Create React App
TypeScript
15
star
61

cypress-realworld-testing-todomvc

A TodoMVC Application for the Testing Your First Application Course in the Real World Testing with Cypress Curriculum
JavaScript
12
star
62

gh-action-and-gh-integration

Example project that uses both Cypress GH Action and Cypress GH Integration
JavaScript
12
star
63

cypress-example-docker-codeship

Cypress + Docker + Codeship Pro = ❤️
Dockerfile
12
star
64

cypress-example-electron

Electron.js application tested with Cypress - WIP
JavaScript
12
star
65

todomvc

Vanilla JS TodoMVC with Cypress Tests
JavaScript
11
star
66

cypress-design

Find here all the components to build UI with the Cypress Brand
TypeScript
10
star
67

cypress-gh-action-vue-example

Testing an app scaffolded with Vue CLI using Cypress GH Action
Vue
10
star
68

cypress-watch-preprocessor

Simple preprocessor that only watches files
JavaScript
8
star
69

netlify-plugin-cypress-example

An example site built and tested on Netlify using netlify-plugin-cypress
CSS
8
star
70

cypress-workshop-ci-example

A simple example app to be used during cypress-workshop-ci session
HTML
7
star
71

cypress-example-netlify-store

🛍 A Tested E-Commerce Site with Stripe payment
Vue
7
star
72

feature-maybe

Functional feature toggles on top of any object
JavaScript
6
star
73

cypress-icons

Cypress logos, icons, favicons, tray, iconset
JavaScript
6
star
74

cypress-parcel-preprocessor

Cypress preprocessor for bundling JavaScript via Parcel
JavaScript
6
star
75

cypress-test-module-api

[ARCHIVED] Example running specs using Cypress via its module API
JavaScript
6
star
76

full-network-proxy

Demo repo for Cypress with full network stubbing support
JavaScript
5
star
77

circleci-orb-parallel-example

Using Cypress CircleCI Orb to quickly run tests in parallel
JavaScript
5
star
78

v8-snapshot

Tool to create a snapshot for Electron applications.
TypeScript
5
star
79

cypress-heroes-app

Demo app for Cypress
TypeScript
5
star
80

cypress-repeat-retry

Stress-testing Cypress test retries
JavaScript
5
star
81

bumpercar

[ARCHIVED] Easily update settings and trigger builds across projects and CI providers
CoffeeScript
4
star
82

component-testing-quickstart-apps

Apps from the Cypress Component Testing quickstart guides
HTML
4
star
83

get-windows-proxy

Node.js module that finds a user's system proxy settings depending on their platform.
JavaScript
4
star
84

error-message

User-friendly error text with additional information
JavaScript
4
star
85

cypress-load-test

JavaScript
3
star
86

generator-node-cypress

Yeoman generator for PUBLIC Node packages from Cypress.io team
JavaScript
3
star
87

cypress-migrator

Apps and libraries related to the Cypress Migrator tool
TypeScript
3
star
88

cypress-adapter-ruby

Cypress Ruby Driver
Ruby
3
star
89

testing-workshop-cph

End-to-end testing workshop with Cypress at CopenhagenJS
JavaScript
3
star
90

jsnation-example

TodoMVC example tests for JSNation conference
JavaScript
3
star
91

eslint-plugin-dev

Common ESLint rules and configuration shared by Cypress packages
JavaScript
3
star
92

cypress-chrome-recorder-extension

JavaScript
2
star
93

mksnapshot

A rewrite of electron/mksnapshot to support multiple electron versions.
TypeScript
2
star
94

cypress-ct-definition-template

Template for authoring Component Framework Definitions
TypeScript
2
star
95

debugging-proxy

A simple, pass-through HTTP proxy that works with HTTP/HTTPS. For debugging applications to make sure they still work behind a proxy.
JavaScript
2
star
96

3rd-party-error

Example showing 3rd party JavaScript error
JavaScript
2
star
97

cypress-test-ci-environments

[ARCHIVED] Confirms that missing Xvfb or dependencies can be detected by Cypress
JavaScript
2
star
98

env-or-json-file

Loads JSON object from environment string or local file
JavaScript
2
star
99

cypress-onboarding-demo

JavaScript
1
star
100

circleci-orb-example

Cypress CircleCI Orb example
JavaScript
1
star