# Debug a single failing test in Qwik with Atlas in 2026

> Atlas helps Qwik developers find why one specific test fails and fix the code, not the assertion, by running `vitest` in isolation and navigating the call graph.

Atlas empowers Qwik developers in 2026 to efficiently debug a single failing test by integrating directly with the Qwik toolchain, including `vitest` for running tests, `pnpm` for package management, and `prettier` for code formatting. Atlas uses its `bash` tool to execute specific `vitest` commands, then leverages `lsp` for code navigation and `edit` to apply precise fixes to your Qwik components and modules.

## Key takeaways

- Atlas uses `bash` to run `pnpm vitest` with precise filters, isolating single Qwik test failures.
- The `lsp` tool in Atlas navigates Qwik's `component$`, `useSignal`, and `routeLoader$` definitions to trace execution.
- Atlas's `edit` tool allows for temporary logging and direct code fixes within Qwik modules like `src/routes`.
- All Qwik code changes by Atlas are presented as unified diffs for approval, ensuring developer control.
- Atlas integrates `pnpm prettier` into the workflow, maintaining Qwik code formatting standards automatically.

## How to run a single Qwik test with Atlas and Vitest

To debug a specific failing test in Qwik, Atlas uses its `bash` tool to execute `pnpm vitest` with a focused filter, ensuring only the relevant test runs. This approach, mirroring manual debugging, significantly reduces output noise, making it 10 times easier to pinpoint issues in your `src/routes` or component$ definitions.

Atlas initiates the debugging process by running the single failing test in isolation. Instead of executing the entire test suite, Atlas uses its `bash` tool to invoke `pnpm vitest` with the `--testNamePattern` flag. For example, if a test named 'should render the counter component' in `src/components/counter/counter.test.ts` is failing, Atlas would execute a command similar to `pnpm vitest --testNamePattern "should render the counter component"`. This precise filtering, a core capability of `vitest`, ensures that Atlas receives minimal, focused output, allowing it to concentrate on the specific assertion failure. This is crucial for Qwik applications, where component$ definitions and routeLoader$ exports can have complex interactions, and isolating the problem is the first step towards a fix.

## Navigating Qwik code with Atlas's LSP tool

Once a single Qwik test fails, Atlas employs its `lsp` tool to work through the Qwik codebase, tracing the execution path from the failing assertion back to the root cause. This involves using `goToDefinition` and `findReferences` to explore `component$` definitions, `useSignal` state, and `routeAction$` exports, providing a 360-degree view of the code under test.

After identifying the failing test output, Atlas utilizes its `lsp` tool to understand the code exercised by the test. Atlas reads the test file, such as `src/components/hero/hero.test.ts`, and the Qwik module it exercises, for instance, `src/components/hero/hero.tsx`. Using `lsp`'s `goToDefinition` operation, Atlas can jump from a failing assertion to the exact line of code in a `component$` or `routeLoader$` that is being tested. Subsequently, `findReferences` helps Atlas trace how `useSignal` or `useStore` state is manipulated across different parts of the Qwik application, including within `routeAction$` exports. This deep understanding of the call graph, facilitated by Atlas's AST indexing via tree-sitter, is essential for debugging Qwik's resumable architecture, where the `$` boundary dictates what code ships to the browser.

## Hypothesizing and fixing Qwik code with Atlas edit

Atlas forms a hypothesis about the Qwik test failure and checks it by adding temporary logging or re-running tests with verbose flags, all through its `edit` and `bash` tools. This iterative process allows Atlas to refine its understanding of issues within `src/routes` or `component$` logic, often requiring just 1 or 2 cycles to pinpoint the exact problem.

With a clear understanding of the call path, Atlas formulates a hypothesis about the root cause of the Qwik test failure. To validate this, Atlas can use its `edit` tool to insert temporary `console.log()` statements directly into the Qwik component$ or service code, for example, within a `routeLoader$` in `src/routes/dashboard/index.tsx`. Alternatively, Atlas can re-run the `vitest` command using its `bash` tool with additional verbose flags, such as `pnpm vitest --verbose`, to gain more insight into the test execution. Once the hypothesis is confirmed, Atlas uses `edit` to apply the necessary fix to the production code. For changes spanning multiple hunks or files, like refactoring a `useStore` definition across several `component$` files, Atlas can use `apply_patch` to ensure a cohesive and atomic update, maintaining the integrity of the Qwik codebase.

## Reviewing and applying changes in Qwik with Atlas

Atlas ensures every proposed change to your Qwik codebase, from a simple `edit` to a complex `apply_patch`, is permission-gated and presented as a unified diff for your approval. This transparent process, which includes running `pnpm prettier` over touched components, guarantees that all 100% of code modifications meet your standards before being written to disk.

Before any changes are written to your Qwik project, Atlas computes a unified diff for every file edit and surfaces it for your approval. This critical safety mechanism ensures that you, the developer, have full control over the modifications. For instance, if Atlas proposes a fix to a `component$` in `src/components/button/button.tsx` or adjusts a `routeAction$` with `zod$` validation, you will see the exact lines added, removed, or modified. Atlas also integrates with your existing Qwik development workflow by automatically running `pnpm prettier` over any touched components after a fix, ensuring that the code adheres to your project's formatting standards, as defined in your `prettier.config.js` or `.prettierrc`. This final review step, combined with Atlas's ability to snapshot file changes as git patches, provides a robust and reversible debugging experience.

## Steps

1. Initiate Atlas in your Qwik project, ensuring it can read your `vite.config.ts` and `src/routes` structure.
2. Ask Atlas to 'Debug the failing test named "should render the user profile" in `src/routes/profile/profile.test.ts`'. Atlas will use `bash` to run `pnpm vitest --testNamePattern "should render the user profile"`.
3. Review the `vitest` output provided by Atlas. If the assertion is unclear, ask Atlas to 'Use `lsp` to go to definition of the failing assertion in `src/routes/profile/profile.test.ts`'.
4. Ask Atlas to 'Walk the call graph from the assertion to the `routeLoader$` in `src/routes/profile/index.tsx` using `lsp`'s `findReferences`'.
5. Form a hypothesis and ask Atlas to 'Add a temporary `console.log()` statement to the `routeLoader$` in `src/routes/profile/index.tsx` using `edit` to check the value of `userData`'.
6. Ask Atlas to 'Re-run the single test with `bash`' to observe the new logging output and confirm the hypothesis.
7. Instruct Atlas to 'Fix the `routeLoader$` logic in `src/routes/profile/index.tsx` using `edit` to correctly fetch `userData`'.
8. Approve the unified diff presented by Atlas for the code changes. Atlas will then run `pnpm prettier` over the modified `src/routes/profile/index.tsx`.
9. Ask Atlas to 'Re-run the single test with `bash`' to confirm the fix, then 'Run the full `pnpm vitest` suite with `bash`' to ensure no regressions.
10. Finally, ask Atlas to 'Remove the temporary `console.log()` statement from `src/routes/profile/index.tsx` using `edit`'.

## FAQ

### How does Atlas run only one specific Qwik test?

Atlas uses its `bash` tool to execute `pnpm vitest` with the `--testNamePattern` flag, targeting the exact test name or a regex pattern. This leverages `vitest`'s built-in filtering capabilities to run only the specified test in your Qwik project, minimizing output and focusing the debugging effort.

### Can Atlas help me understand Qwik's resumability during debugging?

Yes, Atlas's `lsp` tool, powered by AST declarations, helps you understand Qwik's resumability by tracing code across `$` boundaries. It can show you how `component$`, `routeLoader$`, and `routeAction$` interact, and how `useSignal` or `useStore` state is managed, which are key aspects of Qwik's architecture.

### What Qwik-specific files does Atlas interact with?

Atlas interacts with core Qwik files and configurations, including `vite.config.ts` (especially for the `qwikCity` plugin), `src/routes` for pages and API endpoints, and component files containing `component$`, `useSignal`, `useStore`, `routeLoader$`, and `routeAction$` definitions. It also respects `prettier` configuration files.

### How does Atlas ensure code quality after a Qwik fix?

After Atlas applies a fix to your Qwik codebase, it can automatically run `pnpm prettier` over the modified files. This ensures that any changes adhere to your project's established formatting standards, maintaining code consistency and quality without manual intervention.

### Is it safe to let Atlas modify my Qwik code?

Yes, Atlas prioritizes safety. Every tool call is permission-gated, and all proposed code edits are presented as a unified diff for your explicit approval before being written to disk. Atlas also snapshots file changes as git patches, allowing for easy rollback if needed, providing a secure debugging environment for your Qwik project.

### Can Atlas debug issues related to Qwik's `$` boundary or `zod$` validation?

Absolutely. Atlas can help debug issues related to Qwik's `$` boundary by analyzing how code is chunked and serialized. For `routeAction$` with `zod$` validation, Atlas can use `lsp` to inspect the validation schema and `edit` to adjust the validation logic or the data being passed, identifying discrepancies that cause test failures.

---

Canonical HTML: https://runatlas.sh/resources/stacks/debug-a-failing-test-in-qwik
Source of truth: aeo_pages row `/resources/stacks/debug-a-failing-test-in-qwik` (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.
