Skip to content

Commit 7e14e09

Browse files
author
Abhi Singh
committed
adds local test and xml reports
1 parent d46ec4f commit 7e14e09

File tree

12 files changed

+61
-743
lines changed

12 files changed

+61
-743
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ node_modules
22
screenshots
33
videos
44
downloads
5-
mochawesome-report
65
report
76
log
87
*.log

README.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Cypress is a next generation front end testing tool built for the modern web. Cucumber is a software tool that supports behavior-driven development (BDD).
66

7-
This BrowserStack Example repository demonstrates a Cypress framework with parallel testing capabilities. The Cypress test scripts are written for the open source [BrowserStack Demo web application](https://bstackdemo.com) ([Github](https://github.com/browserstack/browserstack-demo-app)). This BrowserStack Demo App is an e-commerce web application which showcases multiple real-world user scenarios. The app is bundled with offers data, orders data and products data that contains everything you need to start using the app and run tests out-of-the-box.
7+
This BrowserStack Example repository demonstrates a Cypress framework with parallel testing capabilities. The Cypress test scripts are written for the open source [BrowserStack Demo web application](https://bstackdemo.com) ([Github](https://github.com/browserstack/browserstack-demo-app)).
88

99
The Cypress tests are run on different platforms like on-prem and BrowserStack using various run configurations and test capabilities.
1010

@@ -18,18 +18,11 @@ You need BrowserStack credentials to be able to run Cypress tests. You have to r
1818

1919
1. Clone this repository
2020
2. Install the dependencies using `npm install`
21-
3. Run the sample script using `npm run bstack`
21+
3. Run the sample script using `npm run sample-test`
2222

2323
## Run sample test on privately hosted websites
2424

25-
1. Clone the [BrowserStack demo application](https://github.com/browserstack/browserstack-demo-app) repository.
26-
27-
```sh
28-
git clone https://github.com/browserstack/browserstack-demo-app
29-
```
30-
31-
2. Please follow the README.md on the BrowserStack demo application repository to install and start the dev server on localhost.
32-
3. You can then run the sample Local test using `npm run bstack-local`
25+
Run the sample Local test using `npm run sample-local-test`
3326

3427
## Additional Resources
3528

run_conf/browserstack.json renamed to browserstack.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,26 @@
77
{
88
"browser": "chrome",
99
"os": "Windows 10",
10-
"versions": ["latest", "latest-1"]
10+
"versions": ["latest"]
1111
},
1212
{
13-
"browser": "edge",
14-
"os": "Windows 10",
15-
"versions": ["latest", "latest-1"]
13+
"browser": "webkit",
14+
"os": "OS X Ventura",
15+
"versions": ["latest"]
1616
},
1717
{
1818
"browser": "firefox",
19-
"os": "OS X Mojave",
20-
"versions": ["latest", "latest-1"]
19+
"os": "OS X Big Sur",
20+
"versions": ["latest"]
2121
}
2222
],
2323
"run_settings": {
24-
"downloads": ["./mochawesome-report"],
2524
"cypress_config_file": "./cypress.config.js",
2625
"project_name": "BrowserStack Examples",
27-
"build_name": "cucumber-js-cypress-cucumber",
26+
"build_name": "browserstack-build-1",
27+
"downloads": ["./results"],
2828
"exclude": [],
29-
"parallels": "5",
29+
"parallels": "3",
3030
"npm_dependencies": {
3131
"browserstack-cypress-cli": "^1.19.3",
3232
"cypress": "^12.5.1",
@@ -42,7 +42,7 @@
4242
"headless": true
4343
},
4444
"connection_settings": {
45-
"local": false,
45+
"local": true,
4646
"local_identifier": null,
4747
"local_mode": null,
4848
"local_config_file": null

cypress.config.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@ const cucumber = require("cypress-cucumber-preprocessor").default;
33

44
module.exports = defineConfig({
55
watchForFileChanges: true,
6-
reporter: "mochawesome",
6+
experimentalWebKitSupport: true,
7+
reporter: "junit",
8+
reporterOptions: {
9+
mochaFile: "results/test-results-[hash].xml",
10+
},
711

812
e2e: {
913
setupNodeEvents(on, config) {
1014
on("file:preprocessor", cucumber());
1115
},
12-
specPattern: "**/*.feature",
13-
baseUrl: "https://bstackdemo.com/",
16+
specPattern: "**/e2e.feature",
17+
baseUrl: "https://bstackdemo.com/signin",
1418
excludeSpecPattern: ["*.js"],
1519
},
1620
});

cypress/e2e/local.feature

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Feature: Local Feature
2+
3+
@local
4+
Scenario: Local Scenario
5+
Given I navigate to local website
6+
Then I should see sample local page

cypress/support/step_definitions/e2e.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const purchase = new Purchase();
1111
const orders = new Orders();
1212

1313
Given("I navigate to website", () => {
14-
cy.visit(Cypress.config().baseUrl + "signin");
14+
cy.visit(Cypress.config().baseUrl);
1515
});
1616

1717
And("I SignIn as {string} with {string} password", (username, password) => {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const { Given, Then } = require("cypress-cucumber-preprocessor/steps");
2+
3+
Given("I navigate to local website", () => {
4+
cy.visit(Cypress.config().baseUrl);
5+
});
6+
7+
Then("I should see sample local page", () => {
8+
cy.title().should("equal", "BrowserStack Local Website");
9+
});

cypress_local.config.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@ const cucumber = require("cypress-cucumber-preprocessor").default;
33

44
module.exports = defineConfig({
55
watchForFileChanges: true,
6-
reporter: "mochawesome",
6+
experimentalWebKitSupport: true,
7+
reporter: "junit",
8+
reporterOptions: {
9+
mochaFile: "results/test-results-[hash].xml",
10+
},
711

812
e2e: {
913
setupNodeEvents(on, config) {
1014
on("file:preprocessor", cucumber());
1115
},
12-
specPattern: "**/*.feature",
13-
baseUrl: "http://localhost:3000/",
16+
specPattern: "**/local.feature",
17+
baseUrl: "http://localhost:8081/",
1418
excludeSpecPattern: ["*.js"],
1519
},
1620
});

index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>BrowserStack Local Website</title>
8+
</head>
9+
<body>
10+
<h1>Sample Website</h1>
11+
</body>
12+
</html>

0 commit comments

Comments
 (0)