Set up testing in your project
“Add Vitest to my project for unit testing. Set up the configuration file and create a simple example test that passes. Also add a test script to my package.json so I can run tests easily.”
Free AI prompt · The Optimize Book
A ready-to-use prompt from the chapter Testing Basics. Paste it into Claude, ChatGPT, Lovable, Bolt or any AI coding tool.
“Set up Playwright for end-to-end testing. Create tests that: open the homepage, check the navigation links work, fill out the main form and submit it, and verify the success page appears. Make the tests run in headless mode.”
“Add Vitest to my project for unit testing. Set up the configuration file and create a simple example test that passes. Also add a test script to my package.json so I can run tests easily.”
“Write tests for my contact form. Test that: the form renders correctly, required fields show an error when submitted empty, the email field rejects invalid emails, and a successful submission shows a confirmation message. Use Vitest and React Testing Library.”
“Look at my project and write tests for the most critical user flows. Focus on anything involving forms, authentication, or data submission. Use Vitest for unit tests and explain what each test checks.”
“Add basic tests to my app. Write tests for my [component/function/API route] that check [expected behavior]. Use Vitest and Testing Library.”
“My app has a bug where [describe bug]. Write a test that reproduces this bug, then fix the code so the test passes.”
“Review my project and tell me if it's ready to go live. Check for: any leftover test URLs that point to my computer instead of the real site, any missing API keys or settings, any large unoptimized images, any debug messages left behind, any missing error pages, and any missing SEO tags. List everything I need to fix before I publish.”