How to Run Cypress Tests for your Create-React-App Application
On This Page Why use Create-React-App to build your coveringJanuary 09, 2026 · 8 min read · Tool Comparison
When edifice coating with Create-React-App, insure your UI behaves as expected is key to delivering a smooth user experience. Cypress offers a straightforward and reliable way to automate testing immediately in the browser, making it easier to catch number before they hit production. Create-React-App is a popular tool that simplifies setting up React applications with a ready-to-use development surround. Running Cypress tests on a Create-React-App project helps automate end-to-end examination, ensuring your app works smoothly while speeding up bug detection and improving codification reliability. Benefits of Running Cypress Tests for Create-React-App This clause research the procedure of running Cypress tests on your Create-React-App project, assist you progress more robust and maintainable React applications with self-assurance. There are several reasons why you might choose to use Create React App over early choice for building your covering: Read More: Running Cypress test on a Create-React-App provides various key benefits that improve both the development workflow and the overall quality of the application: To further enhance testing efficiency, offers a robust cloud-based platform that enable running Cypress tryout across a wide range of existent browser and devices. This ensures comprehensive test coverage and faster delivery cycles by validating app behavior in environments that closely match. To explore component try with Create React App, start by creating an application that includes a component examination. The sample app allow searching through a list of pre-populated name Before installation and using Cypress for constituent testing, ensure all necessary dependencies are download and installed to run the application successfully. 1. Download the Github repositorywith the application. 2. Open the downloaded depository in VScode. 3. Click Terminal & gt; New Terminal. 4. Install the required dependencies: 5. Start the ontogeny server: 6. Verify the waiter is up and scat atlocalhost:5173. The following ikon shows the folder structure of the app: The autocomplete.jsxfile include the state variables declaration: It include theonChangeevent that will be triggered when a user starts typing and searching for a name. It likewise include theonClickevent that will be triggered when a exploiter clicks a name from the list that populates. ThekeyDowncase listens for keyboard navigation that a user performs. The Suggestions component holds the logic to return suggestions based on the user debut. Read More: To pen a component test for the component describe earlier, we need to establish Cypress. 1. Open the downloaded repository in VScode. 2. Click Terminal & gt; New Terminal. 3. Run the following command to instal Cypress: SUSA automates exploratory testing with persona-driven behavior, catching bugs that scripted automation misses. 4. Run the following command to open Cypress splashboard: Also Read: The component test to be written for the app will cover the next: Read More: To add the test to the app: After you have added the component test to your component, you can run the test using the Cypress dashboard. 1. In VSCode, clickTerminal & gt; New Terminal. 2. Run the next code: 3. Click Component Testing & gt; Chrome, and so clickStart Component Testing in Chrome. 4. In the Cypressfascia, dogSpecsand double-click theautocomplete.cy.jsx file. The test is consummate and the effect appears as follow: Read More: For running the Cypress E2E examination, using thebstackdemoweb app. The test will sign in using an account, log out the current exploiter, and then verify to be on the Sign in page. Prerequisite Before you can create the E2E specification for testing, you must install the cypress-xpath addiction. Create an empty spec using the E2E testing selection that Cypress provides. 1. In VSCode, clickTerminal & gt; New Terminal. 2. Run the following command to open Cypress: 3. Click E2E Testing & gt; Chrome, and then clickStart E2E Testing in Chrome. 4. Click Continueto create an empty specification. 5. Set the name of the test ase2e.cy.jsand click Create spec. 6. In VSCode, open thecypress/e2e folder. 7. Open thee2e.cy.js file. 8. Copy the next code: 1. In VSCode, open the directory,bstackdemo-e2e. 2. Click Terminal & gt; New Terminal. 3. Run the next command to open Cypress: 4. Click E2E Testing & gt; Chrome, and then clickStart E2E Testing in Chrome. 5. In the Cypressfascia, clickSpecsand double-click thee2e.cy.js file. Read More: The test is complete and establish the result as follows: Read More: Some of the good recitation that you can note before creating Cypress test cases are: For enhanced testing efficiency, supply seamless integration with Cypress, enabling tests to run across 3500+ real browser and devices in the cloud. With and local examination capabilities, BrowserStack helps speed up examination runs and securely test applications hosted behind firewalls. Efficacious testing is crucial to building dependable application, and Cypress offers a powerful solution tailored for Create-React-App projects. By setting up and run both component and end-to-end examination with Cypress, developers can catch topic early, check smooth user experiences, and accelerate development round. Adhering to outdo practices farther enhances test stability and maintainability, making Cypress an essential tool for modern React development. On This Page # Ask-and-Contributeabout this topic with our Discord community. Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed. Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.How to Run Cypress Tests for your Create-React-App Application
Overview
Why use Create-React-App to construct your application
Why use Cypress for Testing Create-React-App Applications?
Set up the Create React App
Understand the App
npm install
npm run dev
Understand the Component
Install Cypress in the App
npm install cypress -- save-dev
npx cypress unfastened
Write the component test for Create-React-App expend Cypress
import Autocomplete from './autocomplete '; meaning countries from ' .. /data/countries '; describe ('Test the autocomplete functionality ', () = & gt; {beforeEach (() = & gt; {cy.mount (& lt; Autocomplete countries= {countries} / & gt;);}) it ('check everything is working in ui ', () = & gt; {cy.get (' [data-cy= '' head ''] ') .contains ('Search your land: '); cy.get ('input [type= '' text ''] ') .should ('have.value ', ``); cy.get (' [data-cy= '' suggestion-list ''] ') .should ('not.exist ');}) it ('check filter is act ', () = & gt; {cy.get ('input [type= '' text ''] ') .type ('no '); cy.get (' [data-cy= '' suggestion-list ''] ') .should ('be.visible ') .as ('suggestList '); cy.get (' @ suggestList ') .should ('have.length ', 1);}) it ('check selections are working ', () = & gt; {cy.get ('input [type= '' text ''] ') .as ('inputText '); cy.get (' @ inputText ') .type ('no ') .type (Cypress._.repeat (' {downArrow} {downArrow} ', 1)); cy.get (' [data-cy= '' suggestion-list ''] li: nth-child (3) ') .should ('have.class ', 'active '); cy.get (' @ inputText ') .type (Cypress._.repeat (' {upArrow} ', 1)); cy.get (' [data-cy= '' suggestion-list ''] li: nth-child (2) ') .should ('have.class ', 'active '); cy.get (' [data-cy= '' suggestion-list ''] li: nth-child (2) ') .click (); cy.get ('input [type= '' text ''] ') .should ('have.length ', 1); cy.get (' [data-cy= '' suggestion-list ''] ') .should ('not.exist ');})})Run Component trial for Create-React-App using Cypress
npx cypress open
E2E test for Create-React-App employ Cypress
npm install cypress-xpath
Write the E2E tryout for Create-React-App using Cypress
npm cypress open
require ('cypress-xpath '), describe ('empty specification ', () = & gt; {it ('Bstack demo signin ', () = & gt; {cy.visit ('https: //bstackdemo.com/signin ') cy.get (`` # username '') .click (); cy.xpath (`` //div [schoolbook () ='demouser '] '') .click (); cy.get (`` # parole '') .click (); cy.xpath (`` //div [schoolbook () ='testingisfun99 '] '') .click (); cy.get (`` # login-btn '') .click (); cy.get (`` # logout '') .should ('have.text ', 'Logout ') cy.get (`` # logout '') .click (); cy.get (`` # signin '') .should ('have.text ', 'Sign In ')})})Run your Cypress E2E examination for Create-React App
npm cypress open
Best Practices for scarper Cypress Tests on Create-React-App
Conclusion
Related Guides
Automate This With SUSA
Test Your App Autonomously