commands.ts 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. declare global {
  3. // eslint-disable-next-line @typescript-eslint/no-namespace
  4. namespace Cypress {
  5. interface Chainable<Subject> {
  6. /**
  7. * Simulates a paste event.
  8. * Modified from https://gist.github.com/nickytonline/bcdef8ef00211b0faf7c7c0e7777aaf6
  9. *
  10. * @param subject A jQuery context representing a DOM element.
  11. * @param pasteOptions Set of options for a simulated paste event.
  12. * @param pasteOptions.pastePayload Simulated data that is on the clipboard.
  13. * @param pasteOptions.pasteFormat The format of the simulated paste payload. Default value is 'text'.
  14. * @param pasteOptions.files A list of assisiated file, if any
  15. *
  16. * @returns The subject parameter.
  17. *
  18. * @example
  19. * cy.get('body').paste({
  20. * pasteType: 'application/json',
  21. * pastePayload: {hello: 'yolo'},
  22. * });
  23. */
  24. paste(options: {
  25. pastePayload?: string
  26. pasteFormat?: string
  27. files?: File[]
  28. }): Chainable<Subject>
  29. selectText(direction: 'left' | 'right', size: number): Chainable<Subject>
  30. matchImage(
  31. options?: Partial<{
  32. // screenshot configuration, passed directly to the the Cypress screenshot method: https://docs.cypress.io/api/cypress-api/screenshot-api#Arguments
  33. // default: { }
  34. screenshotConfig: Partial<Cypress.ScreenshotOptions>
  35. // pixelmatch options, see: https://www.npmjs.com/package/pixelmatch#pixelmatchimg1-img2-output-width-height-options
  36. // default: { includeAA: true }
  37. diffConfig: Partial<{
  38. // Matching threshold, ranges from 0 to 1. Smaller values make the comparison more sensitive. 0.1 by default.
  39. threshold: number
  40. // If true, disables detecting and ignoring anti-aliased pixels.
  41. includeAA: boolean
  42. // Blending factor of unchanged pixels in the diff output. Ranges from 0 for pure white to 1 for original brightness. 0.1 by default.
  43. alpha: number
  44. // The color of anti-aliased pixels in the diff output in [R, G, B] format. [255, 255, 0] by default.
  45. aaColor: [number, number, number]
  46. // The color of differing pixels in the diff output in [R, G, B] format. [255, 0, 0] by default.
  47. diffColor: [number, number, number]
  48. // An alternative color to use for dark on light differences to differentiate between "added" and "removed" parts. If not provided, all differing pixels use the color specified by diffColor. null by default.
  49. diffColorAlt: [number, number, number] | null
  50. // Draw the diff over a transparent background (a mask), rather than over the original image. Will not draw anti-aliased pixels (if detected).
  51. diffMask: boolean
  52. }>
  53. // whether to update images automatically, without making a diff - useful for CI
  54. // default: false
  55. updateImages: boolean
  56. // directory path in which screenshot images will be stored
  57. // image visualiser will normalise path separators depending on OS it's being run within, so always use / for nested paths
  58. // default: '__image_snapshots__'
  59. imagesDir: string
  60. // maximum threshold above which the test should fail
  61. // default: 0.01
  62. maxDiffThreshold: number
  63. // forces scale factor to be set as value "1"
  64. // helps with screenshots being scaled 2x on high-density screens like Mac Retina
  65. // default: true
  66. forceDeviceScaleFactor: boolean
  67. // title used for naming the image file
  68. // default: Cypress.currentTest.titlePath (your test title)
  69. title: string
  70. }>,
  71. ): Chainable<Subject>
  72. mount: typeof import('cypress/vue')['mount']
  73. }
  74. }
  75. }
  76. export {}