Skip to content

bahmutov/cypress-think

Repository files navigation

⚠️ Not ready to be used yet.


cypress-think

Create Cypress tests using your own AI

📺 Watch Introducing cypress-think.

Given cy.think(...) command, comes up with accurate Cypress commands line by line

Input spec

Produces the following test, see line by line generated commands

Passing test

Input prompt

Can be a single line, multi-line literal, or an array of strings

cy.think('Visit the site')
cy.think(`
  visit the site
  // comments are ignored
  click on the "Sign in" button
`)
cy.think([
  'visit the site',
  'click on the "Home" thumbnail',
  'url should include "/home"',
])

Agent instructions

This package automatically discovers your agent instructions and includes them with your prompts, see agent-instructions.mjs

Found agent instructions in: .github/copilot-instructions.md

Caching

Each prompt line is processed separately. Each result is cached to avoid reinventing the same code. If the line changes, it will be re-generated.

Caching symbol

The cache is loaded and saved in the local thoughts.json file.

Saving generated code

If the entire prompt finishes successfully, a save icon 💾 appears next to the "thinking" log message

Save replaces the original .think(prompt) with the generated .within(...) commands plus comments

Save icon

Here is before and after spec file

Saving generated code

Placeholders

You can use dynamic values, while the AI query stays unchanged via placeholders option

const name = 'Ann Marie'
cy.think(
  'enter {{name}} into the input with placeholder "Enter name"',
  {
    placeholders: { name },
  },
)

The AI query is going to be enter {{name}} into..., while the actual command will enter "Ann Marie"

Placeholders test

Debugging

This plugin uses debug to output debug logs to STDERR.

# show debug logs: commands, results
$ DEBUG=cypress-think npx cypress open
# show HTML sent to the model (verbose)
$ DEBUG=cypress-think:html npx cypress open

See LICENSE.md

About

Create Cypress tests using your own AI

Topics

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •