Skip to content

Commit 4f07809

Browse files
committed
Upgrade cypress tests
1 parent c02eb9a commit 4f07809

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1326
-1025
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ jobs:
3838
- name: Execute tests with defaults
3939
run: |
4040
npm run serve-and-test:parallel
41+
- name: Execute only some tests
42+
run: |
43+
npm run serve-and-test:parallel:some
4144
- name: Execute tests with spec reporter
4245
run: |
4346
npm run serve-and-test:parallel:spec

cypress-parallel

Lines changed: 0 additions & 1 deletion
This file was deleted.

cypress.config.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const { defineConfig } = require('cypress')
2+
3+
module.exports = defineConfig({
4+
video: false,
5+
e2e: {
6+
// We've imported your old cypress plugins here.
7+
// You may want to clean this up later by importing these.
8+
setupNodeEvents(on, config) {
9+
return require('./cypress/plugins/index.js')(on, config)
10+
},
11+
baseUrl: 'http://localhost:3000',
12+
},
13+
})

cypress.json

Lines changed: 0 additions & 1 deletion
This file was deleted.
File renamed without changes.
Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
describe('Delete pizza', () => {
22
beforeEach(() => {
3-
cy.server();
4-
cy.fixture('pizzas').as('pizzasAPI');
3+
4+
cy.fixture('pizzas').then((pizzas) => {
5+
cy.intercept({
6+
method: 'DELETE',
7+
url: '/api/pizzas/*'
8+
}, pizzas).as('deletePizza');
9+
10+
cy.intercept({
11+
method: 'GET',
12+
url: '/api/pizzas'
13+
}, pizzas).as('getPizzas');
14+
});
515
cy.fixture('addTopping').as('addToppingAPI');
6-
cy.route({
7-
method: 'DELETE',
8-
url: '/api/pizzas/*',
9-
response: {}
10-
}).as('deletePizza');
11-
cy.route({
12-
method: 'GET',
13-
status: 200,
14-
url: '/api/pizzas',
15-
response: '@pizzasAPI'
16-
}).as('getPizzas');
1716

1817
cy.visit('');
1918
});
@@ -31,9 +30,6 @@ describe('Delete pizza', () => {
3130
.contains('Delete Pizza')
3231
.click();
3332

34-
cy.wait('@deletePizza')
35-
.should(res => {
36-
expect(res.status).to.equal(200);
37-
});
33+
cy.wait('@deletePizza').its('response.statusCode').should('eq', 200)
3834
});
3935
});

cypress/integration/4/modify-pizza.spec.js renamed to cypress/e2e/1/modify-pizza.cy.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
describe('Modify pizza', () => {
22
beforeEach(() => {
3-
cy.server();
4-
cy.fixture('pizzas').as('pizzasAPI');
3+
cy.fixture('pizzas').then((pizzas) => {
4+
cy.intercept({
5+
method: 'GET',
6+
url: '/api/pizzas'}, pizzas).as('getPizzas');
7+
});
8+
59
cy.fixture('addTopping').as('addToppingAPI');
6-
cy.route({
10+
11+
cy.intercept({
712
method: 'PUT',
813
url: '/api/pizzas/*'
914
}).as('addTopping');
10-
cy.route({
11-
method: 'GET',
12-
status: 200,
13-
url: '/api/pizzas',
14-
response: '@pizzasAPI'
15-
}).as('getPizzas');
1615

1716
cy.visit('');
1817
});
@@ -33,7 +32,7 @@ describe('Modify pizza', () => {
3332
.click();
3433

3534
cy.wait('@addTopping')
36-
.its('requestBody')
35+
.its('request.body')
3736
.then(res => {
3837
expect(res.toppings).to.deep.equal([
3938
{ id: 6, name: 'mushroom' },
@@ -62,7 +61,7 @@ describe('Modify pizza', () => {
6261
.click();
6362

6463
cy.wait('@addTopping')
65-
.its('requestBody')
64+
.its('request.body')
6665
.then(res => {
6766
expect(res.toppings).to.deep.equal([
6867
{ id: 10, name: 'pepperoni' },
@@ -88,7 +87,7 @@ describe('Modify pizza', () => {
8887
.click();
8988

9089
cy.wait('@addTopping')
91-
.its('requestBody')
90+
.its('response.body')
9291
.then(res => {
9392
expect(res.toppings).to.deep.equal([
9493
{ id: 10, name: 'pepperoni' },

cypress/integration/1/new-pizza.spec.js renamed to cypress/e2e/1/new-pizza.cy.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
describe('Create pizza', () => {
22
beforeEach(() => {
3-
cy.server();
4-
cy.fixture('pizzas').as('pizzasAPI');
5-
cy.route({ method: 'POST', url: '/api/pizzas' }).as('postNewPizza');
6-
cy.route({
7-
method: 'GET',
8-
status: 200,
9-
url: '/api/pizzas',
10-
response: '@pizzasAPI'
11-
}).as('getPizzas');
3+
4+
cy.fixture('pizzas').then((pizzas) => {
5+
cy.intercept('GET', '/api/pizzas', pizzas).as('getPizzas');
6+
});
7+
8+
cy.intercept({ method: 'POST', url: '/api/pizzas' }).as('postNewPizza');
129

1310
cy.visit('');
1411
});
@@ -43,7 +40,7 @@ describe('Create pizza', () => {
4340

4441
// This test intentionally fail
4542
cy.wait('@postNewPizza')
46-
.its('requestBody')
43+
.its('request.body')
4744
.then((res) => {
4845
expect(res.name).to.equal('My new pizza');
4946
expect(res.toppings).to.deep.equal([

cypress/integration/2/pizza.spec.js renamed to cypress/e2e/1/pizzas.cy.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
describe('Pizza', () => {
22
beforeEach(() => {
3-
cy.server();
4-
cy.fixture('pizzas').as('pizzasAPI');
5-
cy.route({
6-
method: 'GET',
7-
status: 200,
8-
url: '/api/pizzas',
9-
response: '@pizzasAPI'
10-
}).as('getPizzas');
3+
cy.fixture('pizzas').then((pizzas) => {
4+
cy.intercept('GET', '/api/pizzas', pizzas).as('getPizzas');
5+
});
116

127
cy.visit('');
138
});
File renamed without changes.

0 commit comments

Comments
 (0)