All jobs

Write Vitest Tests for Nuxt Server Routes

An agent adds 25 Vitest tests for a Nuxt app's TMDB composables, its /api route and its proxy, stubbing the TMDB HTTP calls; 105 tests pass, up from 80.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

The agent reads vitest.config.ts, server/api/index.ts, app/composables/tmdb.ts and the separate proxy/ Nitro app. The Nuxt app's own server/api/ has a single route, the /api banner; the TMDB endpoint lives in proxy/routes, so it tests both.

app/composables/tmdb.nuxt.test.ts runs every tmdb.ts function for real, covering caching, retry after a failure and the copyright blocklist, and answers the proxy URL with registerEndpoint. server/api/index.test.ts boots the app with @nuxt/test-utils/e2e setup in a new server Vitest project. proxy/tests/tmdb.http.test.ts stubs Nitro's globals and the global fetch, so the real ofetch client runs and the outgoing request to api.themoviedb.org never leaves the process.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "Write tests with @nuxt/test-utils and Vitest for this Nuxt app's server API routes and composables, stubbing only the external TMDB HTTP calls at the network boundary. Run them and open a pull request.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
  1. Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
  2. Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
  3. Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

What comes back

Tried on nuxt/movies at 4d05739: 4 files changed, 337 insertions(+), three new test files and 9 lines in vitest.config.ts. ./node_modules/.bin/vitest run went from Tests 80 passed | 1 skipped (81) to Tests 105 passed | 1 skipped (106), exit 0, and eslint . exited 0 after the change (not run before), after one test/prefer-lowercase-title fix. The sandbox had Node 22 against the repo's ^24, so npx vitest refused with EBADDEVENGINES and the agent ran the binary directly; it had installed pnpm 11.1.2 itself before pnpm install. git commit failed for lack of a git identity, so the work stayed uncommitted; no pull request was opened.

For the reviewer: the server project builds the whole app, so the suite went from about 15 seconds to about 32. A new $fetch URL in the composables needs a matching stub() call, or its test makes a real request.

Run it on every night at 2:00 a.m. Pacific

An automation with a schedule trigger, cron 0 2 * * * and timezone America/Los_Angeles, runs this request overnight in the Project's repository. This trial's sandbox had Node 22 and no git identity, which is why it called the Vitest binary directly and left its four files in the working tree. The EBADDEVENGINES refusal means a nightly run needs Node 24.

The use case this job follows, with its automation and trigger: Write the missing tests.

Why run it on Rush?

The task named server API routes, but this repository's real HTTP work sits in a second app, proxy/, which the agent found and covered, including that the TMDB API key is masked in error bodies. It also caught its own wrong stub: replacing $fetch or fetch did not stop the composables' requests from reaching the live proxy, and only registerEndpoint kept them off the network.

Frequently asked questions

Which routes are still untested?

The other two files in proxy/routes, index.ts and ipx/[...path].ts. The run lists them as gaps.

Is the NUXT_B7021 warning a failure?

No. The untouched clone prints the same warning about a missing client build manifest, and both runs exited 0.

More Nuxt jobs

More jobs like this: Write the missing tests

Keep reading