# Write unit tests for untested code in Nuxt with Atlas in 2026

> Atlas helps Nuxt developers add `vitest (@nuxt/test-utils)` unit tests to untested modules, respecting existing conventions and ensuring code quality.

Atlas helps Nuxt developers in 2026 add real unit tests to untested modules by reading existing code, identifying exported symbols, and then writing new specs using `vitest (@nuxt/test-utils)` and `pnpm`, ensuring tests match your repository's established conventions before `prettier` formats the output. This process ensures comprehensive coverage and adherence to your project's specific Nuxt toolchain.

## Key takeaways

- Atlas uses `lsp` to find all exported symbols in Nuxt modules for comprehensive testing.
- `grep` helps Atlas match your existing `vitest (@nuxt/test-utils)` conventions in Nuxt projects.
- The `write` tool drafts new Nuxt test files, showing a clear diff for approval before saving.
- `bash` executes `pnpm vitest` and processes test results, handling large outputs efficiently.
- Atlas ensures Nuxt code is formatted with `prettier` after edits, maintaining code style.
- Permission-gated tools and diff review provide full control over Atlas's changes to your Nuxt codebase.

## How does Atlas find untested functions in a Nuxt module?

Atlas identifies untested functions in a Nuxt module by leveraging its `lsp` tool to enumerate all exported symbols, ensuring comprehensive coverage for your codebase in 2026. This process begins by reading the target module, such as a `composables/` file, to understand its structure.

To begin adding tests, Atlas first uses its `read` tool to ingest the content of the Nuxt module you want to test. For instance, if you have a file like `composables/useMyModule.ts` that lacks tests, Atlas will read its contents. Following this, Atlas employs the `lsp` tool's `documentSymbol` operation. This powerful capability allows Atlas to parse the module's Abstract Syntax Tree (AST) using tree-sitter, identifying and listing every exported symbol,be it a function, a composable, or a variable. This ensures that no public function or export within your Nuxt module is overlooked, providing a complete inventory of what needs testing. Atlas's indexing by AST declarations, rather than blind line windows, guarantees precision in this symbol enumeration.

## How does Atlas match existing `vitest` conventions in Nuxt?

Atlas matches existing `vitest` conventions in your Nuxt project by using its `grep` tool to find and analyze existing test files, ensuring new tests align with your repository's established style. This approach guarantees that any new `vitest (@nuxt/test-utils)` specs written in 2026 will direct integrate.

Consistency is crucial in any codebase, especially when adding new tests. Atlas addresses this by using its `grep` tool to search your Nuxt project for existing `vitest` test files. For example, Atlas might search for files matching patterns like `*.test.ts` or `*.spec.ts` within your `tests/unit/` directory. By analyzing these existing files, Atlas learns your repository's specific testing framework setup, import styles (e.g., how `defineStore` or `useFetch` are mocked), and naming conventions for test suites and individual tests. This allows Atlas to replicate these established patterns when writing new spec files, ensuring that the new `vitest (@nuxt/test-utils)` tests it generates for your Nuxt modules look and feel as if they were written by a human developer already familiar with your project's standards. This prevents the introduction of inconsistent testing practices.

## How does Atlas write new `vitest` unit tests for Nuxt?

Atlas writes new `vitest` unit tests for Nuxt modules using its `write` tool, drafting a new spec file that incorporates identified symbols and matches existing conventions. Before any changes land on disk, Atlas presents a unified diff for your approval, ensuring transparency in 2026.

Once Atlas has identified the symbols to test and understood your Nuxt project's existing `vitest` conventions, it proceeds to draft the new spec file. This is done using the `write` tool. For a module like `composables/useMyModule.ts`, Atlas might propose a new file such as `composables/useMyModule.test.ts`. This new file will contain `vitest (@nuxt/test-utils)` test blocks, importing the necessary module and setting up basic test cases for each exported symbol. A critical safety feature of Atlas is that it computes a unified diff for every proposed file edit. This diff is surfaced for your approval in the permission prompt, allowing you to review exactly what changes Atlas intends to make before anything is written to disk. This ensures you maintain full control over your Nuxt codebase. After the tests are written and approved, Atlas can also ensure the new `.ts` files are formatted correctly by running `prettier` via the `bash` tool.

## How does Atlas run and debug `vitest` tests in Nuxt?

Atlas runs `vitest` tests in Nuxt projects using its `bash` tool, executing `pnpm vitest` and processing the output to identify failures. If test logs exceed 2000 lines or 50 KB, Atlas truncates the display but saves the full log for review in 2026.

Writing tests is only half the battle; running them is the point. Atlas uses its `bash` tool to execute your Nuxt project's `vitest` suite. This typically involves running the command `pnpm vitest`. Atlas captures the output of the test run, reading the failures to understand what needs fixing. For very verbose test runs, where output might exceed 2000 lines or 50 KB, Atlas intelligently truncates the displayed output in the terminal to keep the interface manageable. However, it always saves the full log to a file, which you can then inspect at your leisure. If tests fail, Atlas facilitates an iterative debugging process. You can use the `edit` tool to modify the test file or the module under test directly within Atlas. For larger Nuxt modules or complex test suites, Atlas also offers the `todowrite` tool, allowing you to keep a structured list of progress and remaining tasks, ensuring you systematically work towards a green test suite.

## How does Atlas ensure safe Nuxt code changes and test additions?

Atlas ensures safe Nuxt code changes and test additions through a multi-layered security approach, including permission-gated tool calls and explicit approval of all edits. Every Atlas tool call is permission-gated against allow, ask, and deny rules before it runs, providing robust control in 2026.

Safety and control are paramount when an AI agent modifies your codebase. Atlas is designed with several mechanisms to ensure that all changes, including adding `vitest` tests to your Nuxt project, are made securely and with your explicit consent. Firstly, every Atlas tool call,whether it's `read`, `write`, `bash`, or `edit`,is permission-gated. You can configure `allow`, `ask`, or `deny` rules for each tool, giving you granular control over what Atlas can execute. Secondly, Atlas drafts a plan in a read-only plan agent and asks for your approval before switching to a build agent that can make changes. Thirdly, for every file edit, Atlas computes a unified diff and surfaces it for your approval before writing anything to disk. This visual confirmation allows you to review the exact changes. Furthermore, Atlas reads git branches, status, and diffs, and can stage and create commits on your behalf, or snapshot file changes as git patches, so edits can be easily diffed and rolled back if needed. This comprehensive approach ensures that your Nuxt project remains secure and under your control throughout the testing workflow.

## Steps

1. Read the Nuxt module: Use `atlas read` to ingest the target Nuxt module (e.g., `composables/useMyModule.ts`) and `atlas lsp documentSymbol` to enumerate its exported symbols, ensuring no public function is missed.
2. Identify Nuxt test conventions: Employ `atlas grep` to locate an existing `vitest` test file (e.g., `tests/unit/example.test.ts`) within your Nuxt project to replicate its framework, import style, and naming conventions for `@nuxt/test-utils`.
3. Draft new `vitest` spec: Instruct `atlas write` to generate the new `vitest` spec file (e.g., `composables/useMyModule.test.ts`), incorporating the identified symbols and matching the established Nuxt test conventions. Review the unified diff presented by Atlas.
4. Run Nuxt unit tests: Execute the test suite using `atlas bash pnpm vitest`. Atlas will read the test failures, truncating output over 2000 lines or 50 KB while saving the full log to a file.
5. Iterate and refine: Use `atlas edit` to modify the test file or the module under test based on failures. For larger Nuxt modules, manage progress with `atlas todowrite` to track remaining tasks until the suite is green.
6. Format Nuxt code: After tests pass, allow Atlas to run `atlas bash pnpm prettier --write .` over the touched `.vue` and `.ts` files to ensure consistent formatting across your Nuxt project.
7. Review and commit: Review the final diffs presented by Atlas, then approve the changes. Atlas can stage and create commits on your behalf, ensuring a clean git history for your Nuxt project.

## FAQ

### How does Atlas know which Nuxt functions to test?

Atlas uses the `lsp` tool's `documentSymbol` operation to enumerate all exported symbols from your Nuxt modules, such as those in `composables/` or `server/api/`, ensuring comprehensive test coverage for public functions.

### Can Atlas adapt to my existing `vitest` setup in Nuxt?

Yes, Atlas employs the `grep` tool to search your Nuxt project for existing `vitest` test files, learning your repository's specific framework, import style, and naming conventions to apply them to new tests via `@nuxt/test-utils`.

### What test runner does Atlas use for Nuxt projects?

For Nuxt projects, Atlas leverages `vitest` through `@nuxt/test-utils`, executing tests via the `bash` tool with commands like `pnpm vitest` to integrate direct with your development workflow.

### How does Atlas ensure my Nuxt code changes are safe?

Atlas operates with permission-gated tool calls, drafts plans in a read-only agent, and presents a unified diff for every file edit, requiring your explicit approval before any changes are written to your Nuxt codebase.

### Does Atlas format the Nuxt test files it creates?

Yes, after writing and iterating on test files, Atlas can run `prettier` over the touched `.vue` and `.ts` files in your Nuxt project using the `bash` tool to maintain consistent code style and adhere to project standards.

### How does Atlas handle large Nuxt modules during testing?

For large Nuxt modules, Atlas can use the `todowrite` tool to help you manage and track progress on remaining test tasks, allowing for iterative development until the entire suite is green and fully tested.

### Can Atlas help with Nuxt-specific testing scenarios like SSR?

Atlas is paired with Nuxt, respecting its file-based routing, auto-imports, and the server/client split of Nitro. It can assist with tasks like adding Nitro route handlers and covering them with `vitest` through `@nuxt/test-utils`.

---

Canonical HTML: https://runatlas.sh/resources/stacks/write-unit-tests-for-untested-code-in-nuxt
Source of truth: aeo_pages row `/resources/stacks/write-unit-tests-for-untested-code-in-nuxt` (segment: Stacks) (this file is generated from it, never hand-edited).
Licence: Atlas is proprietary with a free core. It is not open source and there is no public source repository.
