Skip to content

Commit 7400f99

Browse files
docs: Add self-healing description (#6328)
* docs: Add self-healing description * add / fix links * small updates * lint * remove extra line
1 parent 45b166a commit 7400f99

File tree

4 files changed

+59
-5
lines changed

4 files changed

+59
-5
lines changed

docs/api/commands/prompt.mdx

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: 'cy.prompt() - Generate Cypress Tests with Natural Language and AI'
3-
description: Generate Cypress tests from plain English using AI. Automate test creation, reduce maintenance, and enable self-healing with cy.prompt.
3+
description: AI-powered Cypress command for developers and QA teams. Generate Cypress tests from plain English, get self-healing selectors, and reduce end-to-end test maintenance with cy.prompt.
44
sidebar_label: prompt
55
slug: /api/commands/prompt
66
e2eSpecific: true
@@ -11,7 +11,7 @@ sidebar_custom_props: { 'new_label': true }
1111

1212
# prompt
1313

14-
`cy.prompt` is a Cypress command that uses AI to convert natural language test steps into executable Cypress tests. You can view the generated Cypress code at any time using the **Code** button in the Command Log, giving you full visibility into what commands were created from your prompts.
14+
`cy.prompt` is a Cypress command that uses AI to convert natural language test steps into executable Cypress tests. It helps developers and QA engineers generate tests faster, experiment with self-healing end-to-end tests, and reduce ongoing test maintenance. You can view the generated Cypress code at any time using the **Code** button in the Command Log, giving you full visibility into what commands were created from your prompts.
1515

1616
**`cy.prompt` supports two flexible workflows:**
1717

@@ -28,7 +28,8 @@ You can choose the workflow that fits your project's needs.
2828
- [Choosing your workflow](#Choose-your-workflow) — decide between one-time generation or continuous self-healing
2929
- [How to write effective prompts](#How-to-write-effective-prompts) — craft clear, reliable natural language steps
3030
- [What you can do](#What-you-can-do) — explore supported actions and capabilities
31-
- [Viewing and exporting generated code](#Viewing-and-exporting-generated-code) — see the Cypress code generated from your prompts and save it to your files
31+
- [See self-healed steps in the Command Log](#See-self-healed-steps-in-the-Command-Log) — understand exactly what changed and which element the step resolved to
32+
- [View and export generated code](#View-and-export-generated-code) — see the Cypress code generated from your prompts and save it to your files
3233
- [Setup](#Setup) — enable the command and configure authentication
3334

3435
:::
@@ -41,6 +42,12 @@ You can choose the workflow that fits your project's needs.
4142

4243
_The demo above shows `cy.prompt` in action with [Cypress Studio](/app/guides/cypress-studio)._
4344

45+
## Why use cy.prompt for AI-powered testing?
46+
47+
- **Reduce test maintenance**: Let AI and self-healing selectors absorb many minor UI changes instead of constantly updating selectors by hand.
48+
- **Accelerate test creation**: Turn plain-English test ideas into runnable Cypress tests without having to hand-write every command.
49+
- **Improve collaboration**: Product owners, QA, and developers can all contribute natural language steps that become real tests.
50+
4451
## Syntax
4552

4653
```typescript
@@ -382,9 +389,56 @@ describe('Campaign Management', () => {
382389
})
383390
```
384391

385-
## Viewing and exporting generated code
392+
## See self-healed steps in the Command Log
393+
394+
cy.prompt self-heals when the element it needs to interact with has changed since the last time the step ran, enabling self-healing Cypress tests that adapt as your UI evolves.
395+
396+
When `cy.prompt` self-heals a step, Cypress makes that change visible directly in the Command Log so you can understand exactly what changed and which element the step resolved to.
397+
398+
<DocsImage
399+
src="/img/api/prompt/cy-prompt-self-healed-command-log.png"
400+
alt="Self-healed tag in the Command Log for a cy.prompt step"
401+
/>
402+
403+
### Command Log
404+
405+
You can see that a step self-healed in three places:
406+
407+
- **Test** - The test entry shows when at least one `cy.prompt` step self-healed during the run.
408+
- **Prompt** - The `cy.prompt` command is marked when one or more of its steps self-healed.
409+
- **Step** - Individual prompt steps show a **Self-healed** tag when the element they resolved to has changed since the last time that step ran.
410+
411+
<DocsImage
412+
src="/img/api/prompt/cy-prompt-self-healed-prompt-level-logs.png"
413+
alt="Console logs for a self-healed cy.prompt step"
414+
/>
415+
416+
### Console logs
417+
418+
Clicking a `cy.prompt` command or an individual self-healed step prints detailed Console logs in the Developer Tools, including:
419+
420+
- **Resolved element** - The selector and element that this step resolved to after self-healing.
421+
- **Cached elements** - The previously resolved elements that the step checked before self-healing.
422+
- **Self-healed** - Whether the element was self-healed.
423+
424+
If the element was self-healed via cache, the Console logs will show the resolved element within the cached elements. If the element was self-healed via AI, the Console logs will not have the resolved element within the cached elements.
425+
426+
<DocsImage
427+
src="/img/api/prompt/cy-prompt-self-healed-step-level-logs.png"
428+
alt="Console logs for a self-healed cy.prompt step"
429+
/>
430+
431+
This level of detail makes it easy to tell whether a self-heal reflects an intentional product change or an unexpected behavior so you can refine or rewrite the step if necessary.
432+
433+
### Self-healed status definitions
434+
435+
**Self-Healed via Cache** - A selector changed since the last time `cy.prompt` ran and the element resolved to another element using the existing cache entry. In this case, `cy.prompt` did **not** call AI; the cached mapping was able to resolve the new element.
436+
437+
**Self-Healed via AI** - A selector changed since the last time `cy.prompt` ran and the element resolved to another element via an AI call because there was no matching cache entry.
438+
439+
## View and export generated code
386440

387-
At any time during or after a test run, you can view the exact Cypress code that `cy.prompt` generated from your natural language steps. This transparency is built into every `cy.prompt` execution.
441+
At any time during or after a test run, you can view the exact Cypress code that `cy.prompt` generated from your natural language steps. Combined with the self-healed tags and Console details in the Command Log, this gives you a clear, auditable record of what happened during `cy.prompt` execution so you can debug AI-generated tests and reduce flaky end-to-end tests over time. This transparency is built into every `cy.prompt` execution.
388442

389443
### How to view generated code
390444

114 KB
Loading
39.2 KB
Loading
38.6 KB
Loading

0 commit comments

Comments
 (0)