commands.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // ***********************************************
  2. // This example commands.js shows you how to
  3. // create various custom commands and overwrite
  4. // existing commands.
  5. //
  6. // For more comprehensive examples of custom
  7. // commands please read more here:
  8. // https://on.cypress.io/custom-commands
  9. // ***********************************************
  10. //
  11. /**
  12. * Check the swagger schema:
  13. *
  14. * @param {string} method API Method in swagger doc, "get", "put", "post", "delete"
  15. * @param {string} path Swagger doc endpoint path, exactly as defined in swagger doc
  16. * @param {*} data The API response data to check against the swagger schema
  17. */
  18. Cypress.Commands.add('validateSwaggerSchema', (method, path, data) => {
  19. cy.task('validateSwaggerSchema', {
  20. file: Cypress.env('swaggerBase'),
  21. endpoint: path,
  22. method: method,
  23. statusCode: 200,
  24. responseSchema: data,
  25. verbose: true
  26. }).should('equal', null);
  27. });
  28. Cypress.Commands.add('getToken', () => {
  29. // login with existing user
  30. cy.task('backendApiPost', {
  31. path: '/api/tokens',
  32. data: {
  33. identity: "[email protected]",
  34. secret: "changeme"
  35. }
  36. }).then(res => {
  37. cy.wrap(res.result.token);
  38. });
  39. });