Stacks

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

Updated 7 min read

Atlas helps Electron developers in 2026 add real unit tests to untested modules by reading existing code, identifying exported symbols, and then generating new @playwright/test specs that match the repository's established conventions. It uses npm to run these tests and prettier to format the new files, ensuring direct integration into your Electron project.

How Atlas identifies untested Electron code for unit testing

In 2026, Atlas streamlines identifying untested Electron code by first using its read tool to ingest the target module's source. It then leverages the lsp tool's documentSymbol operation to enumerate all exported functions and classes, ensuring no public API is missed for testing.

To begin adding unit tests to an untested Electron module, Atlas first employs its `read` tool to fully ingest the module's source code. This initial step provides Atlas with a complete understanding of the module's structure and contents. Following this, Atlas utilizes the `lsp` tool's `documentSymbol` operation. This powerful capability allows Atlas to precisely enumerate every exported symbol within the module, including functions, classes, and variables. This meticulous identification ensures that every public API of your Electron module is considered for test coverage, preventing gaps in your testing strategy. This approach is particularly valuable in Electron applications, where the main and renderer processes, along with `contextIsolation` and `preload` scripts, introduce distinct testing considerations that require a comprehensive understanding of the module's exposed interfaces.

Matching existing Electron test conventions with Atlas

Atlas ensures new Electron unit tests integrate direct by first using the grep tool to locate an existing @playwright/test file within your repository. This allows Atlas to precisely replicate the project's established framework, import style, and naming conventions, saving developers significant time in 2026.

A critical aspect of integrating new tests into an existing Electron project is adhering to established coding and testing conventions. Atlas achieves this by using its `grep` tool to search your repository for an existing `@playwright/test` file. By analyzing this found file, Atlas can accurately infer the project's preferred testing framework setup, import styles (e.g., ES modules or CommonJS), and file naming conventions (e.g., `my-module.spec.ts` or `my-module.test.js`). This capability ensures that any new test files generated by Atlas, such as `src/main/my-module.spec.ts`, will direct blend with your current codebase, reducing review friction and maintaining consistency across your Electron application's test suite. This is especially important for Electron projects where specific configurations for `contextIsolation` or `preload` scripts might be reflected in existing test setups.

Generating and running new @playwright/test specs for Electron

After understanding the module and conventions, Atlas drafts new @playwright/test spec files using its write tool, which presents a unified diff for approval before any changes land on disk. It then executes the test suite with the bash tool, running npm test to validate the 100% new tests immediately.

Once Atlas has a clear understanding of the Electron module's public interface and the repository's testing conventions, it proceeds to draft the new `@playwright/test` spec file. This is accomplished using the `write` tool, which is designed to generate code while maintaining developer control. Before any changes are applied to your disk, Atlas presents a unified diff of the proposed new test file, allowing you to review and approve every line. After approval, Atlas uses its `bash` tool to execute the newly created test suite. This typically involves running `npm test` or `npx playwright test`, which triggers the `@playwright/test` runner. Atlas then captures the output, providing immediate feedback on test failures. If the test output exceeds 2000 lines or 50 KB, Atlas truncates it in the terminal for readability but saves the full log to a file for detailed inspection. This iterative process, often involving the `edit` tool to refine tests and `todowrite` for managing progress on larger modules, continues until the entire suite is green.

Reviewing and approving Electron test changes with Atlas

Atlas prioritizes developer control and safety, presenting a unified diff for every file edit before writing to disk, ensuring you review all proposed @playwright/test changes. This permission-gated approach, combined with automatic prettier formatting, guarantees that new Electron tests meet your project's 2026 code standards.

Developer control and code integrity are paramount when introducing new tests to an Electron project. Atlas ensures this through its permission-gated `write` operations. For every proposed file edit, including the creation of new `@playwright/test` files, Atlas computes and displays a unified diff. This diff clearly highlights all changes, allowing you to meticulously review and explicitly approve them before they are written to disk. This prevents any unintended modifications to your Electron codebase. Furthermore, Atlas integrates direct with `prettier`, the standard formatter for many JavaScript projects, including Electron. After generating new test files, Atlas can automatically run `prettier` to format them, ensuring they conform to your project's established code style without manual intervention. Atlas also reads git branches, status, and diffs, and can stage and create commits on your behalf, and snapshots file changes as git patches, providing robust version control and rollback capabilities for your Electron application.

Step by step

  1. 01Run `atlas read src/main/my-module.ts` to ingest the Electron module's source code.
  2. 02Execute `atlas lsp documentSymbol src/main/my-module.ts` to enumerate all exported symbols for comprehensive @playwright/test coverage.
  3. 03Use `atlas grep "import { test } from '@playwright/test'" src/renderer/existing-test.spec.ts` to find an existing @playwright/test file and copy its conventions.
  4. 04Draft the new @playwright/test spec file with `atlas write src/main/my-module.spec.ts`, reviewing the diff for Electron-specific setup.
  5. 05Run the newly added @playwright/test suite using `atlas bash "npm test"` and observe any failures.
  6. 06Iterate on the test file to fix failures with `atlas edit src/main/my-module.spec.ts`, utilizing `todowrite` for larger Electron modules.
  7. 07Format the new test file to match repo style by running `atlas bash "npx prettier --write src/main/my-module.spec.ts"`.
  8. 08Review staged changes with `atlas git status` and commit the new, passing Electron unit tests.

Frequently asked questions

How does Atlas ensure new Electron unit tests match my existing codebase style?
Atlas uses its `grep` tool to find an existing `@playwright/test` file in your Electron repository. It then analyzes this file to replicate the project's specific import styles, naming conventions, and testing framework setup for new test files.
Can Atlas handle Electron's main and renderer process testing differences?
Yes, Atlas is designed for Electron. It can read your main process, preload scripts, and `ipcRenderer.invoke` calls, allowing it to generate `@playwright/test` cases that drive the packaged app, respecting the main and renderer split and `contextIsolation`.
What test runner does Atlas use for Electron projects?
For Electron projects, Atlas specifically uses `@playwright/test` as the test runner. It generates test files compatible with Playwright and executes them via `npm test` or `npx playwright test` using the `bash` tool.
How does Atlas prevent accidental code changes in my Electron app?
Atlas employs a permission-gated system. Before any `write` operation, it computes and displays a unified diff of the proposed changes. You must explicitly approve these changes, ensuring full control over modifications to your Electron codebase.
Does Atlas help with formatting new Electron test files?
Yes, Atlas integrates with `prettier`. After generating new `@playwright/test` files, Atlas can run `prettier` to automatically format them, ensuring consistency with your Electron project's established code style.
How does Atlas know which functions in my Electron module need tests?
Atlas uses its `lsp` tool with the `documentSymbol` operation on your Electron module. This allows it to enumerate all exported symbols, such as functions and classes, ensuring that every public API is considered for test coverage.
What if the test output is very long when running Electron tests with Atlas?
If the output from running `npm test` with the `bash` tool exceeds 2000 lines or 50 KB, Atlas truncates it in the terminal. The full log is saved to a file, which you can then read to review all details of your Electron test failures.

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 Electron: Terminal-Native AI Coding for Main, Preload, and Renderer in 2026

Atlas is a terminal-native AI coding agent for Electron in 2026, where the main and renderer split, contextIsolation, and preload bridges are the security model.

Plan a Multi-File Change Before Editing in Electron with Atlas in 2026

Design and review complex, multi-file changes for your Electron application using Atlas's plan agent. Leverage real tools like npm, prettier, and @playwright/test, ensuring safety and precision before any code is

Automate GitHub Issue and Pull Request Triage in Electron with Atlas in 2026

Streamline GitHub issue and pull request triage for your Electron applications in 2026. Atlas integrates directly into GitHub Actions, ensuring safe, permission-gated responses and leveraging your existing toolchain.

Audit an Electron Repository with Parallel Subagents in Atlas in 2026

Audit your Electron repository in 2026 for problems without blowing your main session's context window. Atlas uses parallel subagents to sweep your codebase, integrating with `npm`, `@playwright/test`, and `prettier`

Extract a shared helper from duplicated code in Electron with Atlas in 2026

In 2026, Electron developers use Atlas to efficiently extract shared helpers from duplicated code, leveraging semantic search to refactor logic across main and renderer processes. Streamline your Electron codebase.

Review a Pull Request in Electron with Atlas in 2026

In 2026, Electron developers use Atlas to review pull requests, ensuring code quality and security. Atlas leverages @playwright/test, npm, and prettier to catch subtle bugs.

Refactor a legacy module in Electron with Atlas in 2026

Streamline Electron module refactoring in 2026 with Atlas. Safely restructure old code, maintain behavior, and prevent breaking changes using real Electron tools like npm and Playwright.

Browse this resource hub