1 of 14

Writing integration tests with Cypress and Meshery

Rodolfo Martínez Vega

Layer5 CI Working Group Lead

2 of 14

How it works?

3 of 14

Folder structure

  • fixtures: mock data
  • integration: tests here!
  • plugins: env vars, preprocessors, screenshot handling
  • screenshots: images when tests fail
  • support: commands to help us (i.e. login() function)
  • videos: of running the tests

4 of 14

How to write tests?

sample_spec.js

  • *_spec.js: test filename
  • describe() and it() come from Mocha
  • expect() comes from Chai

5 of 14

Meshery provider-ui

cypress/integration/first-test_spec.js

  • cy.visit(): will visit the baseUrl from “cypress.json” (http://localhost:3001)
  • cy functions: can be chained
  • data-cy: recommended for selecting UI elements

6 of 14

Selecting elements

https://docs.cypress.io/guides/references/best-practices.html#Selecting-Elements

7 of 14

Test Runner

$ npm run cy:open

8 of 14

Executing tests

- confidential -

9 of 14

Let’s write tests!

Demo

10 of 14

What’s next?

https://docs.cypress.io/guides/getting-started/writing-your-first-test.html

11 of 14

Best Practices

https://docs.cypress.io/guides/references/best-practices.html

12 of 14

YouTube video:

“Brian Mann – I see your point, but… (Part 1)”

https://www.youtube.com/watch?v=5XQOK0v_YRE

13 of 14

Q&A

14 of 14