Skip to content

Commit 97964ad

Browse files
committed
Add Cypress test automation framework for SauceDemo
1 parent 53a7094 commit 97964ad

35 files changed

+4125
-5196
lines changed

.github/workflows/cypress.yml

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,39 +11,34 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Checkout
14-
uses: actions/checkout@v4
15-
14+
uses: actions/checkout@v3
15+
1616
- name: Setup Node.js
17-
uses: actions/setup-node@v4
17+
uses: actions/setup-node@v3
1818
with:
19-
node-version: 20
19+
node-version: '18'
20+
cache: 'npm'
2021

2122
- name: Install dependencies
2223
run: npm install
2324

2425
- name: Create cypress.env.json
2526
run: |
2627
echo '{
27-
"username": "standard_user",
28-
"password": "secret_sauce"
28+
"users": {
29+
"standard": {
30+
"username": "standard_user",
31+
"password": "secret_sauce"
32+
},
33+
"locked": {
34+
"username": "locked_out_user",
35+
"password": "secret_sauce"
36+
}
37+
}
2938
}' > cypress.env.json
30-
39+
3140
- name: Cypress run
32-
uses: cypress-io/github-action@v6
41+
uses: cypress-io/github-action@v5
3342
with:
3443
browser: chrome
35-
36-
- name: Upload artifacts
37-
uses: actions/upload-artifact@v4
38-
if: always()
39-
with:
40-
name: cypress-report
41-
path: cypress/reports/html
42-
if-no-files-found: warn
43-
44-
- name: Deploy report to GitHub Pages
45-
if: success() && github.ref == 'refs/heads/master'
46-
uses: peaceiris/actions-gh-pages@v3
47-
with:
48-
github_token: ${{ secrets.GITHUB_TOKEN }}
49-
publish_dir: ./cypress/reports/html
44+
headless: true

.gitignore

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
1+
# Dependencies
12
node_modules/
2-
cypress.env.json
3+
4+
# Cypress generated files
35
cypress/videos/
46
cypress/screenshots/
5-
dist/
6-
.DS_Store
7+
cypress/downloads/
8+
9+
# Environment variables with sensitive data
10+
cypress.env.json
11+
12+
# Logs
13+
*.log
14+
npm-debug.log*
15+
16+
# Operating System files
17+
.DS_Store
18+
Thumbs.db
19+
20+
# IDE and editor files
21+
.idea/
22+
.vscode/
23+
*.swp
24+
*.swo

README.md

Lines changed: 46 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,34 @@
1-
# SauceDemo Cypress Tests
1+
# SauceDemo Cypress Test Automation
22

3-
This project contains automated tests for the SauceDemo website using Cypress with TypeScript.
3+
This project contains automated tests for the [SauceDemo](https://www.saucedemo.com) website using Cypress with TypeScript.
44

55
## Test Scenarios
66

7-
1. Valid Login (with Logout)
8-
2. Locked Out User
7+
The following test scenarios are automated:
8+
9+
1. **Valid Login Scenario** - Verify that a user can successfully log in with valid credentials
10+
2. **Locked Out User Scenario** - Verify that an appropriate error message is displayed when a locked out user attempts to log in
911

1012
## Project Structure
1113

1214
```
13-
├── cypress/
14-
├── e2e/ # Test files
15-
│ ├── fixtures/ # Test data
16-
│ ├── pages/ # Page Object Model classes
17-
│ ├── support/ # Custom commands and configuration
18-
│ └── reports/ # Generated test reports
19-
├── cypress.config.ts # Cypress configuration
20-
├── cypress.env.json # Environment variables (not tracked in git)
21-
├── tsconfig.json # TypeScript configuration
22-
├── package.json # Dependencies and scripts
23-
└── README.md # Project documentation
15+
├── .github/workflows # GitHub Actions workflow files
16+
├── cypress/ # Cypress test files
17+
│ ├── e2e/ # Test specs
18+
│ ├── fixtures/ # Test data
19+
│ ├── pages/ # Page objects
20+
│ └── support/ # Support files and custom commands
21+
├── .gitignore # Git ignore file
22+
├── cypress.config.ts # Cypress configuration
23+
├── cypress.env.json # Environment variables (not committed to Git)
24+
├── package.json # Project dependencies and scripts
25+
└── tsconfig.json # TypeScript configuration
2426
```
2527

28+
## Page Object Model
29+
30+
The tests use the Page Object Model pattern to create a layer of abstraction between the test code and the UI. Page objects are in the `cypress/pages` directory.
31+
2632
## Installation
2733

2834
1. Clone the repository
@@ -32,28 +38,41 @@ This project contains automated tests for the SauceDemo website using Cypress wi
3238
npm install
3339
```
3440

35-
## Running Tests
41+
3. Create a `cypress.env.json` file with the following content:
42+
43+
```json
44+
{
45+
"users": {
46+
"standard": {
47+
"username": "standard_user",
48+
"password": "secret_sauce"
49+
},
50+
"locked": {
51+
"username": "locked_out_user",
52+
"password": "secret_sauce"
53+
}
54+
}
55+
}
56+
```
57+
58+
## Running the Tests
59+
60+
### Headless Mode
3661

3762
To run tests in headless mode:
3863

3964
```bash
4065
npm run cy:run
4166
```
4267

43-
To open Cypress GUI:
68+
### Interactive Mode
69+
70+
To open Cypress in interactive mode:
4471

4572
```bash
4673
npm run cy:open
4774
```
4875

49-
## Reports
50-
51-
Test reports are generated in the `cypress/reports/html` directory after running tests in headless mode.
52-
53-
## GitHub Actions
54-
55-
This project uses GitHub Actions for continuous integration. The workflow installs dependencies and runs the Cypress tests automatically on push or pull request to the master branch.
56-
57-
## Page Object Model
76+
## CI/CD
5877

59-
The tests use the Page Object Model pattern to separate test logic from page-specific selectors and actions, making the tests more maintainable and readable.
78+
This project includes GitHub Actions workflows for continuous integration. Tests are automatically run on push to the master branch and on pull requests to the master branch.

cypress-project/.github/workflows/cypress.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

cypress-project/.gitignore

Lines changed: 0 additions & 18 deletions
This file was deleted.

cypress-project/README.md

Lines changed: 0 additions & 67 deletions
This file was deleted.

cypress-project/cypress.config.ts

Lines changed: 0 additions & 32 deletions
This file was deleted.

cypress-project/cypress/e2e/locked-out-user.cy.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)