Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

. describe('do stuff in my Onlineshop', () => { beforeEach(() => { // Login user using their credentials cy.login('user', 'pass'); }); // … tests will start below })

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

. describe('do stuff in my Onlineshop', () => { beforeEach(() => { cy.get('#sw-field--username').type('username'); cy.get('#sw-field--password').type('pass'); cy.get('.sw-login-login').submit(); cy.contains('Dashboard'); }); // … tests will start below })

Slide 15

Slide 15 text

Use shortcuts: Lösung mit Abkürzung . describe('do stuff in my Onlineshop', () => { beforeEach(() => { cy.request( 'POST', '/api/oauth/token', { // payload: Send all data you need } ).then(() => { cy.contains('Dashboard'); }); }): // … tests will start below })

Slide 16

Slide 16 text

describe('Context menu', () => { it('should open the context menu on click', async () => { const wrapper = createWrapper(); expect(wrapper.vm).toBeTruthy(); await wrapper.trigger('click'); const selector = '.sw-context-menu'; expect(wrapper.find(selector).isVisible()).toBeTruthy(); }); });

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

describe('E2E with AAA pattern‘, () => { it('should open the context menu on click', () => { }); }); // Act // All the steps you need to come to the // scenario to test // Assert // Checks and assertions of your test beforeEach(() => { // Arrange // All the preparations you need });

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

“…arrange my test == what I’m given.” “…act in my test == when something happens.” “…assert the results == something happens then this is what I expect as the outcome.”

Slide 21

Slide 21 text

describe('E2E with Given When Then', () => { it('should use Given When Then', () => { }); }); // When // All the steps +assertions you need to come to the // scenario to test // Then // Scenario to test beforeEach(() => { // Given // All the preparations you need });

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

Isolated test data . describe('Customer login', () => { let customer = {}; beforeEach(() => { // Set application to clean state cy.setInitialState() .then(() => { // Create test data return cy.setFixture('customer'); }) }): // … tests will start below })

Slide 24

Slide 24 text

it('should create and read product', () => { … cy.get('.sw-field—product-name').type('T-Shirt Ackbar'); cy.get('.sw-select-product__select_manufacturer') .type('Space Company’); … });

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

Cypress.Commands.add('typeSingleSelect', { prevSubject: 'element', }, (subject, value, selector) => { … cy.wait(500); cy.get(`${selector} input`) .type(value); });

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

describe('Example test', () => { // Source Cypress docs it('Just doing things', () => { cy.visit('/my/resource/path'); cy.get('.awesome- selector’).click(); let el = Cypress.$('.new-el'); if (el.length) { cy.get('.another-selector'); } else { cy.get('.optional-selector'); } }); });

Slide 31

Slide 31 text

describe(‚Example Test', () => { // Source: Cypress docs it('Doing things right'‚ () => { cy.visit('/my/resource/path') cy.get('.awesome-selector') .click() .then(() => { let el = Cypress.$('.new-el'); if (el.length) { cy.get(‚.another-selector'); } else { cy.get(‚.optional-selector'); }; }); }); });

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

No content