Link Search Menu Expand Document

Cypress Command: clickCopyToEditor

Summary

cy.clickCopyToEditor($codeBlock) - Click the "Copy to Editor" button for the given code block and then validate that the target file contains the copied code

Parameters

  • $codeBlock - The jQuery-wrapped copy-to-editor block to click on, as provied by cy.get()

Examples

cy.contains("a code substring")
  .then($codeBlock => cy.clickCopyToEditor($codeBlock));
cy.get(...)
  .then($codeBlock => cy.clickCopyToEditor($codeBlock));

Waiting

This command will wait until the contents of the file is updated.

Verification

This command will verify that the contents of the copy-to-editor block is contained within the file before continuing.

  • See clickCopyToEditorContaining for a more structured way of finding the copy-to-editor block to click on
  • Before calling this command, you must call watchForVsCodeLoaded to ensure the copy-to-editor block is not clicked before VS Code is ready for interactions

Instruction-Guided

This is an instruction-guided command: By using this command to ask Cypress to click on a copy-to-editor block rather than writing directly to a file, you will avoid having to remember to update your tests every time the contents of the copy-to-editor block changes.