Skip to main content
UI CoveragePremium Solution

additionalInteractionCommands

UI Coverage automatically tracks how elements are used in tests using a predefined set of Cypress interaction commands such as click, type, dblclick, and more.

The additionalInteractionCommands configuration allows you to extend this default set. You can specify custom command types that should also be recognized as interactions, which can increase the range of actions that are counted towards UI Coverage

Why use additionalInteractionCommands?​

  • Custom command support: Track interactions from custom Cypress commands that aren't included in the default set.
  • Third-party library support: Ensure interactions from third-party testing libraries (such as cypress-real-events) are properly recognized and tracked.
  • Enhanced reporting: Improve the accuracy of your UI Coverage reports by including all relevant interaction types.

Syntax​

{
"uiCoverage": {
"additionalInteractionCommands": [
string
]
}
}

Options​

The additionalInteractionCommands property accepts an array of strings, where each string represents a command name that should be treated as an interaction command by UI Coverage.

OptionRequiredDefaultDescription
additionalInteractionCommandsOptional[]An array of command names (strings) that should be recognized as interaction commands in addition to the defaults.

Examples​

Adding custom interaction commands​

Config​

{
"uiCoverage": {
"additionalInteractionCommands": ["customClick", "dragAndDrop", "swipeLeft"]
}
}

Usage in tests​

// These custom commands will now be tracked as interactions
cy.get('[data-testid="submit-button"]').customClick()
cy.get('[data-testid="draggable"]').dragAndDrop()
cy.get('[data-testid="carousel"]').swipeLeft()

Adding third-party library commands​

Config​

{
"uiCoverage": {
"additionalInteractionCommands": ["realClick", "realType", "realHover"]
}
}

Usage in tests​

// Commands from cypress-real-events plugin will be tracked
cy.get('[data-cy="button"]').realClick()
cy.get('[data-cy="input"]).realType('Hello World')
cy.get('[data-cy="tooltip-trigger"]').realHover()

Notes​

  • Command names are case-sensitive and must match exactly as they appear in your test code.
  • The additional commands are merged with the default interaction commands, the default commands are not replaced.
  • Only commands that actually interact with DOM elements should be included in this configuration.
  • Custom commands must log a snapshot that references the subject element. This ensures that the command renders element highlights in Cypress open mode/Test Replay, and also ensures that UI Coverage can properly attribute the interaction to the expected element. More information regarding Custom Commands can be found here.