# Add Missing Tests to Every Pull Request in a Nuxt App

An agent finds what a Nuxt pull request leaves untested in server/api, writes @nuxt/test-utils tests against the built app, and posts a review with a patch.

[Run this on Rush](https://cloud.getrush.ai/run/test-every-pull-request/nuxt/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent reads the diff against `server/api/customers.ts`, `mails.ts`, `members.ts` and `notifications.ts`, each a `defineEventHandler` from `nuxt/server` that returns a static array, and lists what the pull request adds: a query filter, a field, sorting or a new route.

The nuxt-ui-templates/dashboard template has no test runner; its `package.json` stops at `lint` and `typecheck`, which `.github/workflows/ci.yml` runs. The patch adds `vitest` and `@nuxt/test-utils` with pnpm, a `vitest.config.ts` and a `test` script. Each test file calls `setup()` from `@nuxt/test-utils/e2e` to build the app once, then `$fetch('/api/customers')` against it, so the handler runs as Nuxt serves it. Dates built with `date-fns` `sub()` are compared relative to now.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Review this pull request for untested behavior. Check it out and read its diff against the base branch. List each new or changed behavior in server/api that no existing test covers. If the repository has no test runner, add vitest and @nuxt/test-utils with pnpm, a vitest.config.ts and a test script. Write Vitest tests that build the app with setup() from @nuxt/test-utils/e2e and call each route with $fetch, one test per behavior the pull request adds, comparing generated dates relative to now. Run npx vitest run until the new tests pass, then pnpm run lint and pnpm run typecheck. Do not change application code: if a test fails because the code is wrong, keep it out of the patch and describe the failure. Do not push commits, commit to the branch or open a pull request. Post one review on the pull request that lists each untested behavior with file and line, each test you wrote, any test setup you added, the vitest, lint and typecheck results, and the new tests as one patch. If this run names no pull request, in resources or after this prompt, stop and say so.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app/pull/123"
    }
  ]
}
```

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

One review on the pull request: each untested behavior with the `server/api/` file and line, the test that covers it, and the results of `npx vitest run`, `pnpm run lint` and `pnpm run typecheck`. The patch adds files under `test/` and, while no runner exists, the config and dev dependencies. Nothing under `server/` or `app/` changes and no commit is pushed.

A reviewer decides whether to adopt the new test setup, and whether a failing test the agent reported, such as a filter that ignores its query parameter, is a bug in the handler.

## Run it on every pull request opened against main

Give an automation this request as its prompt and a `github` trigger on `pull_request.opened` and `pull_request.synchronize`, with `branch_patterns` `main`. Every pull request an owner, member or collaborator opens or pushes to gets a review; one from a fork gets none. No trigger filters on paths, so a pull request that changes only `app/` pages still starts a run. The event carries the URL and base branch, not SHAs, so the agent checks out the head from the URL.

## Why run it on Rush?

The template's CI lints and typechecks but never calls a route, so a handler that returns the wrong rows passes every check it has. Building the app with `@nuxt/test-utils` and fetching the route is the first check here that exercises `server/api/` at all, and the review shows it against the pull request's own head.

## Frequently asked questions

### Why build the whole app instead of calling the handler?

`setup()` runs the route through Nitro with the `~/types` alias and the `nuxt/server` import resolved as in production, so there is no hand-built event object to drift from the real one.

### Why a patch and not a commit?

The review recipe never pushes, and adding a test runner is a choice for the app's owner. `git apply` takes the tests and the setup together.

## More Nuxt jobs

- [Translate a Nuxt App Into Another Language](https://getrush.ai/run/translate-app-strings/nuxt/)
- [Upgrade Nuxt Dependencies Every Week](https://getrush.ai/run/upgrade-dependencies-weekly/nuxt/)
- [Upgrade Nuxt and Its Modules in a Nuxt App](https://getrush.ai/run/upgrade-nuxt/nuxt/)

## The same job on other stacks

- [Add Missing Tests to Every Pull Request in a Phoenix App](https://getrush.ai/run/test-every-pull-request/phoenix/)
- [Add Missing Tests to Every Pull Request in a Rails App](https://getrush.ai/run/test-every-pull-request/rails/)
- [Add Missing Tests to Every Pull Request in a React App](https://getrush.ai/run/test-every-pull-request/react/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
