Purpose: Run AI-powered autonomous tests (frontend E2E and backend API) via the TestSprite MCP server in Cursor. Docs: TestSprite MCP – Installation, First MCP Test.Documentation Index
Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
- Node.js >= 22
- TestSprite account (free tier available)
- API key from TestSprite Dashboard → Settings → API Keys
1. Install TestSprite MCP in Cursor
TestSprite is provided as an example entry in.cursor/mcp.json.example. Configure it locally with your own API key:
- Open Cursor Settings (e.g.
Ctrl+Shift+J/Cmd+Shift+J). - Go to Tools & Integration → Add custom MCP (or edit existing MCP config).
- Add or update a TestSprite MCP entry with your real API key:
- Replace
YOUR_TESTSPRITE_API_KEYin theenv.API_KEYfield with your key from the dashboard. - Do not commit real API keys. Use a local override or Cursor’s env/secrets if available.
- Replace
- Restart Cursor if needed; confirm the TestSprite MCP server shows as connected (green).
2. Prepare the app
- Frontend (development): From repo root run
npm run dev(app on port 8080). TestSprite will limit to 15 high-priority tests in dev mode. - Frontend (production, recommended for stable runs): Run
npm run build && npm run preview. Confirm the app loads athttp://localhost:8080. When calling testsprite_generate_code_and_execute, setserverMode: "production"so all tests run and the app is more stable (no HMR during login). - Backend/API: If testing APIs, ensure your backend is running and reachable (e.g. Supabase + edge functions per project setup).
- Have a test user (e.g. from
.env.local/ Lovable secrets) for login if testing authenticated flows.
3. Run tests with TestSprite
- Open a new Cursor Chat.
- Type: “Can you test this project with TestSprite?”
- Optionally drag the project folder (or a subfolder) into the chat.
- When the Testing Configuration page opens in the browser, set:
- Testing type: Frontend (UI) and/or Backend (APIs).
- Scope: Code Diff (recent changes) or Codebase (full).
- Test credentials: e.g.
TEST_USER_ADMIN_EMAIL/TEST_USER_ADMIN_PASSWORDif your app requires login. - Application URLs: e.g. Frontend
http://localhost:8080, Backend URL if applicable. - PRD: Upload an existing product/requirements doc (draft is fine); TestSprite will normalize it.
- Let the assistant run the TestSprite tools; it will generate a test plan, run tests in the cloud, and produce reports.
additionalInstruction: Our app uses Supabase auth with an async redirect after Sign In. To avoid most login-related failures, when the assistant calls testsprite_generate_code_and_execute, ask it to pass additionalInstruction with: “After clicking Sign In, wait at least 8 seconds for the Supabase auth redirect to complete before interacting with the page again. The app redirects to /dashboard after successful login. Do NOT retry login if the URL still shows /auth within the first 10 seconds — the redirect is async.” A copy of this text is in testsprite_tests/additional_instruction_auth.txt (inside the gitignored testsprite_tests/ folder) for reference.
4. Where results go
After a run, look for:testsprite_tests/in the project (folder is gitignored):testsprite-mcp-test-report.mdorTestSprite_MCP_Test_Report.md– human-readable report.tmp/test_results.json,tmp/config.json, generated test files (e.g.TC001_*.py).
- Use the report to see pass rate, failures, and suggested fixes.
5. Ensure everything is running (checklist)
Before running TestSprite, confirm the following. Before running TestSprite:- Node.js: Run
node --version— must be >= 22 (TestSprite requirement). - App: Run
npm run dev(development) ornpm run build && npm run preview(production). Confirm the app loads athttp://localhost:8080. For production mode, tell the assistant to useserverMode: "production"when calling generate_code_and_execute. - MCP: In Cursor Settings → MCP, confirm TestSprite shows connected (green). Set
API_KEYin the TestSprite server config. Use.cursor/mcp.json.exampleas a template and keep API keys environment-based. If your API key was ever committed, rotate it at TestSprite Dashboard → Settings → API Keys. - Cursor sandbox: Verify Chat → Auto-Run → Auto-Run Mode is Ask Every Time or Run Everything (see Cursor Sandbox Mode).
- First-time only: If
testsprite_tests/does not exist or is empty, run the bootstrap step (e.g. in Cursor chat: “Can you test this project with TestSprite?” and complete the browser config). This createstestsprite_tests/tmp/config.jsonand laterstandard_prd.jsonandtmp/code_summary.yaml.
Before execute (important):
The TestSprite CLI expectstestsprite_tests/testsprite_frontend_test_plan.json. That file is created when the Cursor assistant calls the generate frontend test plan MCP tool (e.g. as part of “Can you test this project with TestSprite?”). So:
- In Cursor chat, run the full TestSprite flow so that the assistant calls testsprite_generate_frontend_test_plan (with your project path and
needLogin: true). After that,testsprite_frontend_test_plan.jsonshould appear undertestsprite_tests/. - Then run testsprite_generate_code_and_execute (or the CLI command the assistant suggests). Do not run execute until the test plan file exists.
testsprite_tests/tmp/config.jsontestsprite_tests/standard_prd.jsontestsprite_tests/testsprite_frontend_test_plan.json
testsprite_tests/ is in .gitignore so generated reports and config are not committed and API keys/credentials stay out of the repo.
Quick reference
- Get API key: Dashboard → Settings → API Keys
- Set key in Cursor: Use
.cursor/mcp.json.exampletemplate and setenv.API_KEYlocally in Cursor MCP config - Node.js: Run
node --version— must be >= 22 - Start app (dev):
npm run dev(port 8080); tests limited to 15 in dev mode - Start app (prod):
npm run build && npm run preview; useserverMode: "production"for full runs - Auth instruction: Pass
additionalInstructionwith wait-after-Sign-In text (see §3) or usetestsprite_tests/additional_instruction_auth.txt - Trigger test: In chat: “Can you test this project with TestSprite?”
- Configure: Browser form: type, scope, credentials, URLs, PRD
Troubleshooting
| Issue | Fix |
|---|---|
| MCP server not connecting | Check Cursor Settings → Tools & Integration (or MCP); restart Cursor; verify TestSprite shows connected. See §1. Install TestSprite MCP. |
| API key rejected | Confirm env.API_KEY in MCP config matches a key from TestSprite Dashboard → Settings → API Keys. Ensure the key is not committed to the repo. |
| Missing testsprite_frontend_test_plan.json | Rerun the flow so the Cursor assistant calls testsprite_generate_frontend_test_plan; verify testsprite_tests/ contains the file. See §3. Run tests and §5 Before execute. |
| Port 8080 unreachable | Ensure npm run dev (or npm run build && npm run preview) is running and the app loads at http://localhost:8080. See §2. Prepare the app. |
See also: docs/testing/index.md for Vitest, Playwright, and RLS testing.