commands.ts 3.7 KB

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