-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
302 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,64 @@ | ||
# cypress-example-e2e | ||
It's a simple Cypress project which presents how you can set up GitHub Actions to publish the test result on GitHub Page. | ||
# Cypress Example E2E | ||
|
||
Test execution result page can be accessed on: https://bhargav-garlapati.github.io/cypress-example-e2e/ | ||
This repository demonstrates how to set up and run end-to-end tests using Cypress, integrated with a CI/CD pipeline for automated testing. The project is configured to run tests through GitHub Actions, making it easy to execute and publish results automatically. | ||
|
||
[](https://percy.io/b72d4388/web/cypress-example-e2e) | ||
## Features | ||
|
||
- **End-to-End Testing**: Using Cypress to test web applications. | ||
- **CI/CD Integration**: GitHub Actions workflow to run tests on every push. | ||
- **Automated Reporting**: Test results published to GitHub Pages. | ||
- **Cross-browser Testing**: Supports testing on different browsers via Cypress. | ||
- **Configuration**: Configurable for different environments and use cases. | ||
|
||
## Getting Started | ||
|
||
To set up this project locally: | ||
|
||
1. Clone the repository: | ||
```bash | ||
git clone https://github.com/bhargav-garlapati/cypress-example-e2e.git | ||
|
||
2. Install dependencies: | ||
```bash | ||
./init.sh | ||
(This shell script will fetch env variables from GCP and install dependencies) | ||
If you encounter access issues, please create a file named `cypress.env.json` in the root directory of the repository locally, and add the following test secrets: | ||
{ | ||
"BASIC_AUTH_USERNAME": "admin", | ||
"BASIC_AUTH_PASSWORD": "admin", | ||
"USERNAME": "tomsmith", | ||
"PASSWORD": "SuperSecretPassword!", | ||
"test": "test" | ||
} | ||
Next, install dependencies `npm install` | ||
3. Run Tests | ||
```bash | ||
npm run cypress:production | ||
|
||
The tests are automatically triggered on every push request, with the results displayed on GitHub Pages. | ||
|
||
## Test Demos | ||
- A/B Variation | ||
- Accessibility | ||
- Add and Remove Elements | ||
- Basic Auth Test | ||
- Interacting with Checkboxes | ||
- Drag and Drop Items | ||
- Handling Iframes | ||
- Handling JS Alerts, Confirm, and Prompt | ||
- Login Flow test | ||
- Upload file | ||
- UI Visual Testing using Percy (smart UI, Applitools Eyes are coming soon...) | ||
Each test can be run individually or as part of the complete test suite. | ||
|
||
You can view the test execution results here: | ||
https://bhargav-garlapati.github.io/cypress-example-e2e/ | ||
|
||
Percy.io visual regression results:[](https://percy.io/b72d4388/web/cypress-example-e2e) | ||
|
||
License: | ||
This project is licensed under the MIT License. See the LICENSE file for details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
describe('Welcome to the-internet', () => { | ||
const data = require('../fixtures/content.json'); | ||
|
||
it('Accessibility on dynamic_controls h4 tag - Pass', () => { | ||
|
||
// Visit dynamicControls page | ||
cy.visitPage('/dynamic_controls'); | ||
|
||
// Check h3 text | ||
cy.get('h4') | ||
.contains(data.dynamicControls); | ||
|
||
// Inject axe-core and check accessibility | ||
// This will pass | ||
cy.injectAxe() | ||
cy.checkA11y('h4', { | ||
runOnly: { | ||
type: 'tag', | ||
values: ['wcag2a', 'wcag2aa'], | ||
}, | ||
}); | ||
}) | ||
|
||
it('Accessibility on dynamic_controls on p tag - Pass', () => { | ||
|
||
// Visit dynamicControls page | ||
cy.visitPage('/dynamic_controls'); | ||
|
||
// Check h3 text | ||
cy.get('h4') | ||
.contains(data.dynamicControls); | ||
|
||
// Inject axe-core and check accessibility | ||
// This will pass | ||
cy.injectAxe() | ||
cy.checkA11y('p', { | ||
runOnly: { | ||
type: 'tag', | ||
values: ['wcag2a', 'wcag2aa'], | ||
}, | ||
}); | ||
|
||
}) | ||
|
||
it.skip('Accessibility on dynamic_controls on form - Fail', () => { | ||
|
||
// Visit dynamicControls page | ||
cy.visitPage('/dynamic_controls'); | ||
|
||
// Check h3 text | ||
cy.get('h4') | ||
.contains(data.dynamicControls); | ||
|
||
// This will fail | ||
cy.checkA11y('form', { | ||
runOnly: { | ||
type: 'tag', | ||
values: ['wcag2a', 'wcag2aa'], | ||
}, | ||
}); | ||
|
||
}) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
describe('Welcome to the-internet', () => { | ||
const data = require('../fixtures/content.json'); | ||
|
||
it('File upload test demo', () => { | ||
|
||
// Visit upload page | ||
cy.visitPage('/upload'); | ||
|
||
// Check h3 text | ||
cy.get('h3') | ||
.contains(data.fileUploader); | ||
|
||
// Upload file | ||
cy.get("#file-upload").selectFile("cypress/fixtures/content.json"); | ||
|
||
// Click on upload button | ||
cy.get("#file-submit").click(); | ||
|
||
// Check h3 text | ||
cy.get("h3", { timeout: 30000 }).should("have.text","File Uploaded!"); | ||
|
||
// Check uploaded file name | ||
cy.get("#uploaded-files").contains("content.json"); | ||
|
||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
describe('Welcome to the-internet', () => { | ||
const data = require('../fixtures/content.json'); | ||
|
||
// This code is to handle iframes is correct. | ||
// However, herokuapp iframe example reached its billing limit. | ||
// So this test case will fail! | ||
it.skip('Handle Iframes', () => { | ||
|
||
// Visit iframe page | ||
cy.visitPage('/iframe'); | ||
|
||
// Check h3 text | ||
cy.get('h3') | ||
.contains(data.iframeHeading); | ||
|
||
// This is a custom command located in the global-commands file under the support directory. | ||
// It is used to locate the iframe and switch to it. For implementation details, please check the global-commands file. | ||
cy.iframeLocator('[id="mce_0_ifr"]', '[role="menuitem"]:nth-child(2)', ''); | ||
|
||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.