Generate Playwright Code
Generate code when your saved test describes the behavior you want to check. TestVibe uses the Assistant to inspect the app, write Playwright code, and verify it.
Select the saved test, confirm the environment, configuration and model, then follow the generation through to Playwright code you can read.
When automatic block discovery is enabled, creating a draft or saving changed instructions can use AI credits independently of generation, even if no reusable blocks are found. Closing generation setup does not cancel discovery already queued by a save. See Credits and What They Cover.
- Open the test in Tests and save any edits.
- Choose … → Generate. If code already exists, use … → Regenerate.
- Confirm the environment, configuration, and model in Generate test.
- Choose Generate to start.
- Read the conversation and answer any question that needs your input.
Before choosing Generate:
- For a private, local, or VPN-only app, connect a tunnel device first. Keep its terminal open, confirm the device is enabled and online, and check that this project uses it (a pinned device takes precedence over the workspace default). The environment should show Via tunnel. Turning on Use a tunnel alone does not connect a device.
- For a public app, use an internet-reachable URL. A project configured to use a tunnel still needs its selected device even when the URL is public. If you intended direct cloud access, review Settings → Tunnels yourself.
- Save passwords and API keys in Settings → Variables & Secrets, then reference their names, for example
{{secret:PASSWORD}}. Use the same references in Assistant descriptions; do not paste credential values into a prompt, test step, or generated code. Non-sensitive fixture data can remain literal. See Create your first test for an example.
If a device is missing or offline, connect it and choose Generate again. Your saved test remains available while you finish setup. Generation uses workspace credits.
You can choose Run in background and continue using TestVibe. Reopen the test's View progress or Answer question action to return. Closing the conversation does not cancel the job.
After completion, read the outcome and open Code to review the saved test. A failed verification needs attention even if a file was written. Use the failure explanation and available evidence before retrying.
TestVibe generates Playwright code. You can inspect and edit it, but later regeneration may replace manual changes.
Next: Run your first test. For more detail, see Review generation progress.