# Create a test in chat

> Describe a flow, watch Re:agent use your app and save what it did as a test.

Source: https://rehearsal.dev/docs/reagent/create-a-test

Re:agent is the chat in Rehearsal. You describe a flow in plain words. Re:agent uses your app in a real browser, and when the flow works, it saves the steps as a test.

Creating a test needs the **Manage projects** permission. Without it, Re:agent can still answer questions about your tests and runs.

## Start a chat

1. **Pick the project**

   Open **Re:agent** in the sidebar and choose the project in the menu at the top. If the project has one address, Re:agent starts there. If it has more, name the app you mean, or Re:agent asks.

2. **Describe the flow**

   Say what to check, in plain words. Say what should be true at the end, because that becomes the check. For example: "Sign in, create a project called Launch and check that it appears in the project list."

3. **Give it a test account if the flow signs in**

   Re:agent signs in with a test account, the way a person would. Add one under **Re:agent uses** before you start, or when Re:agent asks. See [Test accounts and secrets](https://rehearsal.dev/docs/reagent/test-accounts.md).

4. **Watch Re:agent work**

   A browser opens beside the chat, and each step appears in the chat as it happens. [How Re:agent uses a browser](https://rehearsal.dev/docs/reagent/browser.md) explains what you see.

## While Re:agent works

- **Send a message.** Press `Enter` and your message waits until the reply ends. Press `Cmd+Enter`, or `Ctrl+Enter` on Windows and Linux, to send it into the reply. Re:agent reads it after the current step.
- **Answer a question.** When Re:agent needs something from you, it asks above the chat box and waits. See [Questions from Re:agent](https://rehearsal.dev/docs/reagent/questions.md).
- **Stop.** Press **Stop** in the chat box. The browser keeps its page, and your next message continues from there. Messages that were waiting come back to the chat box.

## When the flow works

Re:agent saves the flow and names the test. A block in the reply follows the test through four stages.

| Stage | What happened |
| --- | --- |
| **Flow saved** | Re:agent saved the steps it took and what proved the flow worked. |
| **Test written** | Rehearsal wrote a Playwright test from the flow. |
| **First run passed** | The test ran once and passed. |
| **Verified in a fresh browser** | The test passed again in a new browser, with nothing left over from before. |

After the last stage, a card shows the test's name, what it checks and how many steps it takes. Click the name or the description to change it.

Press **Run now** to run the test, **Open test** to see its page, or **Watch recording** to replay what Re:agent did.

## If it does not work

- **The test did not pass.** The block names the step where it stopped and quotes what Playwright reported. Press **Retry** to write the test again from the same flow, or describe the flow to Re:agent again.
- **The test could not be written.** Rehearsal could not finish writing it. Check that the test account still exists, and that your computer is connected if the app runs there. Then press **Retry**.
- **Something went wrong on our side.** The block says so. Press **Retry** to run the check again.
- **The flow did not work.** Re:agent can close the browsers without saving anything, and nothing becomes a test. A CAPTCHA is one thing that stops it.

## Change a test

1. **Open the test**

   Open **Tests** and choose the test.

2. **Press Edit in chat**

   A new chat opens with the test named in the chat box. Say what should change.

3. **Let Re:agent walk it again**

   Re:agent opens the test's app with the test's own account and makes the change you asked for. Saving writes a new version of the same test, and the test keeps its name.

The new version takes over once it passes in a fresh browser. Until then, runs use the version before it.

## Next steps

- See [how Re:agent uses a browser](https://rehearsal.dev/docs/reagent/browser.md) and what each step in the chat means.
- Read [From flow to test](https://rehearsal.dev/docs/tests/from-flow-to-test.md) to see how Rehearsal writes and checks the test.
