Stacks

Write unit tests for untested code in Angular with Atlas in 2026

Updated 6 min read

Atlas empowers Angular developers in 2026 to efficiently add unit tests to untested modules, leveraging existing repository conventions and the `ng test` runner. It integrates directly with your Angular CLI workspace, ensuring new specs align with your project's `prettier` formatting and `pnpm` package management. This process ensures comprehensive test coverage for your Angular applications.

How Atlas writes Angular unit tests for existing modules

In 2026, Atlas streamlines the process of writing Angular unit tests for existing modules by first understanding your codebase. It reads the target module, then uses its `lsp` tool to enumerate exported symbols, ensuring 100% coverage of public functions within that module.

Atlas begins by using its `read` tool to ingest the content of the Angular module targeted for testing. This initial step allows Atlas to build a comprehensive understanding of the module's structure and logic. Following this, Atlas employs the `lsp` tool with the `documentSymbol` operation to precisely identify all exported symbols, such as components, services, pipes, or directives. This meticulous enumeration ensures that every public function and class within the Angular module receives appropriate unit test coverage, preventing any oversight. By leveraging its AST-based indexing, Atlas understands the code's declarations, not just blind line windows, making its analysis highly accurate for Angular's structured codebase.

Matching Angular test conventions with Atlas

Atlas ensures new Angular unit tests match your repository's existing conventions by using its `grep` tool to find an example spec file. This approach guarantees consistency in framework usage, import styles, and naming, aligning with your project's `ng test` setup, which is critical for maintaining a codebase that might generate over 2000 lines of test output.

To maintain consistency across your Angular project, Atlas does not invent new testing conventions. Instead, it intelligently adapts to your existing codebase. Atlas utilizes its `grep` tool to search for an existing `*.spec.ts` file within your repository. This example file serves as a blueprint, allowing Atlas to learn your project's specific Jasmine or Karma setup, preferred import statements, component testing patterns, and naming conventions. This ensures that any new spec files generated by Atlas direct integrate with your current testing infrastructure, respecting your `prettier` formatting rules and overall code style, making the new tests indistinguishable from manually written ones.

Writing and running Angular specs with Atlas

After understanding the module and conventions, Atlas drafts the new Angular spec file using its `write` tool, presenting a unified diff for approval. It then executes the tests with `ng test` via the `bash` tool, iterating on failures until the suite is green, often processing output over 2000 lines.

Once Atlas has analyzed the target Angular module and identified the repository's testing conventions, it proceeds to draft the new unit test file. The `write` tool is used to generate the `*.spec.ts` file, and crucially, Atlas presents a unified diff of these changes for your review and explicit approval before anything is written to disk. After approval, Atlas uses its `bash` tool to execute the `ng test` command, running the newly created spec alongside your existing test suite. Atlas monitors the test output, and if failures occur, it uses the `edit` tool to refine the spec. For extensive test outputs exceeding 2000 lines or 50 KB, Atlas truncates the terminal display but saves the full log to a file for detailed review, allowing for efficient iteration until all Angular tests pass.

Reviewing and approving Atlas's Angular code changes

Atlas prioritizes safety and transparency when adding Angular unit tests, presenting every proposed file edit as a unified diff for your approval. Before any tool runs, Atlas drafts a plan in a read-only agent, and every tool call is permission-gated, ensuring you maintain 100% control over your codebase.

Safety and developer control are paramount when using Atlas to modify your Angular codebase. Before any code is written or commands are executed, Atlas drafts a detailed plan in a read-only plan agent, which you review. Every subsequent tool call, whether it's `read`, `write`, or `bash`, is permission-gated, requiring your explicit 'allow', 'ask', or 'deny' input. When Atlas proposes to write or modify an Angular spec file, it generates a unified diff, clearly showing all proposed changes. This diff is presented for your approval, ensuring you have 100% visibility and control over what lands in your `angular.json` configured project. Atlas can also read git branches, status, and diffs, and can stage and create commits on your behalf, streamlining the entire development workflow while maintaining full transparency.

Step by step

  1. 01Run Atlas in your Angular workspace, ensuring an `angular.json` file is present.
  2. 02Use the `read` tool to load the specific Angular module you intend to test.
  3. 03Execute `lsp documentSymbol` to enumerate all exported symbols from the target Angular module, ensuring comprehensive test coverage.
  4. 04Employ the `grep` tool to locate an existing `*.spec.ts` file in your repository to learn its Angular testing conventions.
  5. 05Utilize the `write` tool to draft the new Angular spec file, carefully reviewing the presented unified diff for accuracy.
  6. 06Execute `ng test` via the `bash` tool to run the newly created Angular unit tests and observe the results.
  7. 07Use the `edit` tool to refine the Angular spec file based on any failures reported by `ng test`.
  8. 08Repeat the `bash` and `edit` steps until all Angular unit tests for the module pass successfully.

Frequently asked questions

How does Atlas ensure new Angular tests match my project's style?
Atlas uses its `grep` tool to analyze existing `*.spec.ts` files in your Angular project, learning your specific framework usage, import styles, and naming conventions. This ensures any new spec files it generates align perfectly with your established `prettier` formatting and overall codebase style.
Can Atlas run `ng test` directly?
Yes, Atlas uses its `bash` tool to execute `ng test` directly within your terminal. This allows it to run the newly generated Angular unit tests, read the output, and iterate on failures until the test suite passes, just as you would manually.
What if my Angular test suite generates a lot of output?
If your `ng test` output exceeds 2000 lines or 50 KB, Atlas truncates the display in the terminal but saves the full log to a file. You can then review the complete Angular test output by reading the saved file, ensuring no details are lost.
How does Atlas handle dependency injection in Angular tests?
Atlas reads your Angular modules, components, and dependency injection configurations. When writing new specs, it leverages this understanding to correctly set up test beds and inject services, mirroring how your existing Angular tests handle dependencies.
Is it safe to let Atlas write code in my Angular project?
Yes, Atlas is designed with safety in mind. It operates with permission-gated tool calls and presents a unified diff for every proposed file edit. You must explicitly approve changes before they are written to disk, giving you 100% control over your Angular codebase.
Can Atlas help with large Angular modules that need many tests?
For large Angular modules requiring extensive testing, Atlas can manage progress using its `todowrite` list. This allows you to break down the testing effort into manageable chunks, ensuring comprehensive coverage without losing track of remaining tasks.

Try Atlas in your terminal

The terminal-native AI coding agent. Free core, single binary.

Install Atlas

Related guides

Write Unit Tests for Untested Code with Atlas in 2026

How to write unit tests for untested code with Atlas in 2026: the lsp tool enumerates exported symbols, grep copies repo conventions, and bash actually runs the suite.

Atlas for Angular in 2026

Adopt Atlas, the terminal-native AI coding agent, for your Angular projects in 2026. Enhance development with intelligent code search, secure local embeddings, and granular control over AI actions.

Research a Third-Party API Before Integrating It in Angular with Atlas (2026)

Research a third-party API before integrating it in Angular in 2026: Atlas uses websearch and webfetch behind permission prompts, then verifies with grep and ng test.

Diagnose a Hanging or Long-Running Command in Angular with Atlas in 2026

Diagnose hanging or slow Angular CLI commands like `ng test` or `pnpm install` with Atlas in 2026. Atlas identifies if your Angular script is blocked on input or genuinely slow, getting you unstuck.

Debug a single failing test in Angular with Atlas in 2026

Pinpoint and fix failing Angular tests efficiently in 2026 using Atlas, the terminal-native AI coding agent. Leverage ng test, pnpm, and Atlas's powerful debugging tools.

Refactor a Legacy Module in Angular with Atlas in 2026

Refactor legacy Angular modules safely in 2026 with Atlas. Maintain behavior, track callsites, and ensure code quality using `ng test`, `pnpm`, and `prettier`.

Self-review your working diff before committing in Angular with Atlas in 2026

Catch your own mistakes in Angular applications before they reach review or CI. Atlas, the terminal-native AI agent, helps Angular developers review uncommitted diffs, run ng test, and ensure prettier formatting in 2026.

Migrate a Deprecated API Across Every Callsite in Angular with Atlas in 2026

In 2026, Atlas helps Angular developers systematically migrate deprecated APIs across entire codebases. Leverage `lsp`, `todowrite`, and `apply_patch` to ensure no callsite is missed, with validation via `ng test` and

Browse this resource hub