The QA Role and the testing tools are evolving fast. Cypress recently introduced an experimental feature that could change the way we write automated tests in Cypress. The new cy.prompt
feature will allow us to generate automated tests using natural language prompts. The idea is to write the test steps in plain English, and Cypress will generate the test code automatically.
What is Cypress cy.prompt?
Cypress’ cy.prompt
uses generative AI to translate natural-language instructions directly into executable Cypress code. Rather than manually coding every test step, we can describe actions intuitively, and Cypress will translate that into its own Cypress code. The goal of this feature is to save time and effort for writing the test.
Instead of writing:
cy.visit('/login')
cy.get('#username').type('testUser')
cy.get('#password').type('secret')
cy.get('button[type="submit"]').click()
cy.contains('Welcome, testUser').should('be.visible')
The idea is to write:
cy.prompt([
"Visit login page",
"Enter username 'testUser' and password 'secret'",
"Click login button",
"Verify user sees welcome message"
])
Why is Cypress Adding AI into Testing?
In today’s fast-paced world, software teams face increased demands: faster delivery, higher quality, and ever-growing test coverage. The idea is to use AI in the testing process to make the creation and maintenance of tests quicker and easier:
- Faster Test Creation: Spend less time scripting and more time testing complex scenarios.
- Lower Barrier to Entry: New testers and team members unfamiliar with Cypress syntax can contribute immediately.
- Reduced Test Maintenance: Self-healing capabilities mean fewer broken tests after minor UI changes.
Considerations & Current Limitations
cy.prompt
is currently in experimental phase, and testers should be aware of:
- Accuracy & Stability: Verify generated code carefully during initial use.
- Complex scenarios: Some edge cases might still require manual scripting.
- Early Access: It’s currently available via the Cypress early-access program.
Recommendations and What to Expect
To get the maximum value of this new feature:
- Combine Prompt with Manual Editing: Let AI generate initial tests, then manually enhance or optimize.
- Incremental adoption: Gradually introduce
cy.prompt
to your workflow. - Clear prompts: Use simple, direct language to get the best results from AI.
In the future, I think that Cypress will additionally improve this feature, and the testing with it will be even more efficient. We can probably expect enhanced capabilities for complex interactions and even more accurate selector predictions.
Cypress’ cy.prompt
is a potential game-changer, which can drastically simplify automated test creation. What do you think about Cypress’s new AI-driven feature cy.prompt
? Have you used similar AI-powered testing tools? Let me know your thoughts and experiences in the comments!