Skip to content

Commit 11e6e6a

Browse files
author
Abhi Singh
authored
Updated to Cypress V12 and integrated with Test Observability (#15)
* Updated cypress to v12 * integration with TO * Update bstack-local-single.json
1 parent 0d01a8b commit 11e6e6a

19 files changed

+174
-342
lines changed

cypress.config.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { defineConfig } from 'cypress'
2+
3+
export default defineConfig({
4+
fileServerFolder: '.',
5+
fixturesFolder: 'cypress/fixtures',
6+
trashAssetsBeforeRuns: true,
7+
reporter: 'mochawesome',
8+
chromeWebSecurity: false,
9+
pageLoadTimeout: 60000,
10+
reporterOptions: {
11+
reportDir: 'cypress/report/mochawesome-report',
12+
reportFilename: 'testReport',
13+
charts: true,
14+
overwrite: false,
15+
html: true,
16+
json: false,
17+
timestamp: 'mm/dd/yyyy_HH:MM:ss',
18+
},
19+
e2e: {
20+
// We've imported your old cypress plugins here.
21+
// You may want to clean this up later by importing these.
22+
setupNodeEvents(on, config) {
23+
return require('./cypress/plugins/index.js')(on, config)
24+
},
25+
baseUrl: 'https://bstackdemo.com/',
26+
specPattern: 'cypress/e2e/**/*.spec.ts',
27+
supportFile: false,
28+
},
29+
})

cypress.json

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

cypress/integration/e2e/end_to_end.spec.ts renamed to cypress/e2e/e2e/end_to_end.spec.ts

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,64 +25,32 @@ describe('End to End Scenario', function () {
2525
cy.visit('/');
2626
cy.wait('@apiCheck');
2727

28-
})
29-
30-
it('Click on Sign In link', () => {
31-
3228
cy.intercept('GET', Cypress.config().baseUrl + '_next/static/chunks/pages/signin**').as('signinCheck')
3329
signin.signinButton().click();
3430
cy.wait('@signinCheck', { timeout: 30000 });
3531

36-
})
37-
38-
it('Perform Login', function () {
39-
4032
login.username().should('be.visible').click({ force: true }).type(user.user4.username + '{enter}');
4133
login.password().click({ force: true }).type(user.user4.password + '{enter}');
4234
login.logInButton().click();
4335

44-
})
45-
46-
it('Add three products to cart', () => {
47-
4836
purchase.item1().click({ force: true });
4937
purchase.item2().click({ force: true });
5038
purchase.item3().click({ force: true });
5139

52-
})
53-
54-
it('Click on buy button', () => {
55-
5640
purchase.buyButton().click({ force: true });
5741

58-
})
59-
60-
it('Update address details', () => {
61-
6242
address.firstname().should('be.visible').type('first');
6343
address.lastname().type('last');
6444
address.addressline().type('test address');
6545
address.province().type('test province');
6646
address.postcode().type('123456');
6747

68-
})
69-
70-
it('Make purchase and checkout', () => {
71-
7248
orders.checkout().click();
7349

74-
})
75-
76-
it('Go to Orders', () => {
77-
7850
orders.return().click();
7951
cy.wait(3000);
8052
orders.orders().click();
8153

82-
})
83-
84-
it('Should see elements in the list', () => {
85-
8654
cy.get('.a-fixed-right-grid-inner.a-grid-vertical-align.a-grid-top', { "timeout": 30000 }).should('be.visible').its('length').should('equal', 3);
8755

8856
})

cypress/integration/login/locked_user.spec.ts renamed to cypress/e2e/login/locked_user.spec.ts

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,17 @@ describe('Login as locked_user', function () {
55
cy.fixture('user').then((data) => {
66
user = data
77
})
8-
})
9-
10-
it('Visit BrowserStack Demo Website', () => {
11-
12-
cy.intercept('GET', Cypress.config().baseUrl + 'api/products').as('apiCheck')
138
cy.visit('/');
14-
cy.wait('@apiCheck');
15-
169
})
1710

18-
it('Click on Sign In link', () => {
11+
it('Visit BrowserStack Demo Website', () => {
1912

20-
cy.intercept('GET', Cypress.config().baseUrl + '_next/static/chunks/pages/signin**').as('signinCheck')
2113
cy.get('#signin', { timeout: 30000 }).click();
22-
cy.wait('@signinCheck', { timeout: 30000 });
23-
24-
})
25-
26-
it('Perform Login', function () {
27-
2814
cy.get('#username', { timeout: 30000 }).should('be.visible').click({ force: true }).type(user.user1.username + '{enter}');
2915
cy.get('#password').click({ force: true }).type(user.user1.password + '{enter}');
3016
cy.get('#login-btn').click();
31-
32-
})
33-
34-
35-
it('Account has been locked', () => {
36-
3717
cy.get('.api-error', { timeout: 30000 }).should('be.visible').each(elem => {
38-
3918
cy.wrap(elem.text()).should('equal', 'Your account has been locked.');
40-
4119
});
4220

4321
})
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
describe('Login Feature', () => {
2+
3+
var expected_url = Cypress.config().baseUrl + "signin?favourites=true";
4+
5+
it('Visit BrowserStack Demo Website', () => {
6+
7+
cy.visit('/');
8+
cy.get('#favourites', { timeout: 30000 }).click();
9+
cy.url().should('equal', expected_url);
10+
11+
})
12+
13+
});

cypress/integration/offers/offers_for_mumbai.spec.ts renamed to cypress/e2e/offers/offers_for_mumbai.spec.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,13 @@ describe('Offers for Mumbai geo-location', () => {
1818
});
1919
},
2020
});
21-
22-
})
23-
24-
it('Click on Offers', () => {
25-
2621
cy.get('#offers').click();
27-
28-
})
29-
30-
it('Perform Login', () => {
31-
3222
cy.intercept('POST', Cypress.config().baseUrl + 'api/signin').as('signin')
3323
cy.get('#username', { timeout: 30000 }).should('be.visible').click({ force: true }).type(user.user4.username + '{enter}');
3424
cy.get('#password', { timeout: 30000 }).click({ force: true }).type(user.user4.password + '{enter}');
3525
cy.get('#login-btn', { timeout: 30000 }).click();
3626
cy.wait('@signin', { timeout: 30000 });
3727

38-
})
39-
40-
it('Check Offers available or not', () => {
41-
4228
cy.get('.shelf-item__price', { timeout: 5000 }).should('be.visible');
4329
Cypress.log({
4430
name: 'Known Cypress issue',
@@ -47,5 +33,4 @@ describe('Offers for Mumbai geo-location', () => {
4733

4834
})
4935

50-
5136
});

cypress/integration/product/filter_by_vendor.spec.ts renamed to cypress/e2e/product/filter_by_vendor.spec.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,9 @@ describe('Apply Apple and Samsung Vendor Filter', () => {
77
cy.intercept('GET', Cypress.config().baseUrl + 'api/products').as('apiCheck')
88
cy.visit('/');
99
cy.wait('@apiCheck');
10-
11-
})
12-
13-
it('Apply Apple and Samsung Vendor Filter', () => {
14-
1510
cy.get('[type="checkbox"]', { timeout: 30000 }).check('Apple', { force: true });
1611
cy.get('[type="checkbox"]').check('Samsung', { force: true });
1712
cy.wait(3000);
18-
19-
})
20-
21-
it('Should have items based on the filtering criteria', () => {
22-
2313
cy.get('.shelf-item__price', { timeout: 30000 }).should('be.visible').its('length').should('equal', expected_count_of_products);
2414

2515
})

cypress/integration/product/sort_by_price.spec.ts renamed to cypress/e2e/product/sort_by_price.spec.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,21 @@ describe('Apply Lowest to Highest Order By', () => {
66
cy.visit('/');
77
cy.wait('@apiCheck');
88

9-
})
10-
11-
it('Order by "lowest to highest"', () => {
12-
139
cy.intercept('GET', Cypress.config().baseUrl + 'api/products').as('apiCheckagain')
1410
cy.get('select', { timeout: 30000 }).select('lowestprice');
1511
cy.wait('@apiCheckagain');
1612

17-
})
18-
19-
it('Should see the prices in ascending order', () => {
20-
21-
2213
var prices = new Array()
23-
2414
cy.get('.shelf-item__price', { timeout: 30000 }).children('.val').children('b').each(elem => {
25-
2615
prices.push(parseInt(elem.text()));
27-
2816
}).then(obj => {
2917

3018
var prices_sort = Array.from(prices)
3119
prices_sort = prices_sort.sort((a, b) => a - b)
3220
for (let i = 0; i < prices.length; i++) {
3321
expect(prices[i]).to.be.eq(prices_sort[i])
3422
}
35-
3623
});
37-
3824
})
3925

40-
4126
});

cypress/integration/user/add_to_favourites.spec.ts renamed to cypress/e2e/user/add_to_favourites.spec.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,18 @@ describe('Login as User with existing Orders', function () {
1313
cy.visit('/');
1414
cy.wait('@apiCheck');
1515

16-
})
17-
18-
it('Click on Sign In link', () => {
19-
2016
cy.intercept('GET', Cypress.config().baseUrl + '_next/static/chunks/pages/signin**').as('signinCheck')
2117
cy.get('#signin', { timeout: 30000 }).click();
2218
cy.wait('@signinCheck', { timeout: 30000 });
2319

24-
})
25-
26-
it('Perform Login', function () {
27-
2820
cy.get('#username', { timeout: 30000 }).should('be.visible').click({ force: true }).type(user.user3.username + '{enter}');
2921
cy.get('#password', { timeout: 30000 }).click({ force: true }).type(user.user3.password + '{enter}');
3022
cy.get('#login-btn', { timeout: 30000 }).click();
3123

32-
})
33-
34-
it('Add items to Favourites', () => {
35-
3624
cy.get('#4', { timeout: 30000 }).should('be.visible').children('.shelf-stopper').children('button').click({ force: true });
3725
cy.get('#5').children('.shelf-stopper').children('button').click({ force: true });
3826

39-
})
40-
41-
it('Click on "Favourites" link', () => {
42-
4327
cy.get('#favourites', { timeout: 30000 }).click();
44-
45-
})
46-
47-
it('Should see elements in the list', () => {
48-
4928
cy.get('.shelf-item', { timeout: 30000 }).should('be.visible').its('length').should('be.gt', 0);
5029

5130
})

cypress/integration/user/existing_orders.spec.ts renamed to cypress/e2e/user/existing_orders.spec.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,15 @@ describe('Login as User with existing Orders', function () {
1313
cy.visit('/');
1414
cy.wait('@apiCheck');
1515

16-
})
17-
18-
it('Click on Sign In link', () => {
19-
2016
cy.intercept('GET', Cypress.config().baseUrl + '_next/static/chunks/pages/signin**').as('signinCheck')
2117
cy.get('#signin', { timeout: 30000 }).click();
2218
cy.wait('@signinCheck', { timeout: 30000 });
2319

24-
})
25-
26-
it('Perform Login', function () {
27-
2820
cy.get('#username', { timeout: 30000 }).should('be.visible').click({ force: true }).type(user.user3.username + '{enter}');
2921
cy.get('#password', { timeout: 30000 }).click({ force: true }).type(user.user3.password + '{enter}');
3022
cy.get('#login-btn', { timeout: 30000 }).click();
3123

32-
})
33-
34-
it('Click on "Orders" link', () => {
35-
3624
cy.get('#orders', { timeout: 30000 }).should('be.visible').click();
37-
38-
})
39-
40-
it('Should see elements in the list', () => {
41-
4225
cy.get('.a-box-group.a-spacing-base.order', { timeout: 30000 }).should('be.visible').its('length').should('be.gt', 0);
4326

4427
})

0 commit comments

Comments
 (0)