Cypress is a powerful, open-source testing framework used for end-to-end testing of web applications. It provides a rich set of features for writing and running tests, making it easier to ensure the quality and reliability of your web applications.
The provided tests are basic functionality test that assume a certain structure of your application. Feel free to edit the files in the cypress directory to customize your tests!
- End-to-End (E2E) Testing: These tests simulate real user interactions in the browser to ensure your application behaves as expected.
- Component Testing: This involves testing individual components in isolation to verify their functionality.
To run Cypress tests in this project, follow these steps:
-
Install Cypress: Run the following command to install Cypress as a development dependency:
npm install -D cypress @cypress/react
-
Add Script to
package.json: Add the following line to thescriptssection of yourpackage.json:"test": "eslint src && cypress run --component && cypress run --e2e",
-
Run Tests: Run the following command to run all the tests:
First start the development server:
PORT=8181 npm run devThen run the tests:
PORT=8181 npm run testIf you want to open cypress in the browser you can run:
PORT=8181 cypress openNote: Note the PORT numbers above, this is simply to make sure the dev server is running on the same port as the tests.
If you run into an error where cypress can't connect to your dev server you may need to add this section to your vite.config.js to make sure it reads in the PORT environment variable.
server: {
port: process.env.PORT || 8080,
},By following these steps, you can set up and run Cypress tests to try out your application automatically!