> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bugster.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How to update your tests

> Sync your suite with product changes by creating, modifying, and removing tests via `bugster update`.

Keep your test suite synchronized with code changes. The approach depends on your framework: Next.js and React can use the automatic `bugster update` command, while Angular, Svelte, Vue, and other frameworks use AI-assisted updates with Cursor or Claude Code.

<Info>
  **Framework-specific updates**: Next.js and React use `bugster update` command with automatic routing analysis. Angular, Svelte, Vue, and other frameworks use AI assistance with Cursor or Claude Code Agent rules.
</Info>

In this guide you will learn:

* How to keep your test suite synchronized with your codebase.
* How to use different update modes for local development and CI workflows (Next.js & React).
* How to use AI-assisted updates for other frameworks (Angular, Svelte, Vue & Others).

<Card title="Prerequisites">
  - Bugster CLI installed and authenticated.
  - Run commands from your repo root (the directory containing `/.bugster/`).
  - For Next.js & React PR automation: the Bugster GitHub App is installed on the repo (document required permissions) and PR previews are available if your flow depends on them.
</Card>

## Framework-Specific Approaches

<Tabs>
  <Tab title="Next.js & React">
    **Automatic `bugster update` Command**

    Next.js and React applications can use the `bugster update` command to automatically:

    * Create tests for new functionality
    * Modify tests impacted by code changes
    * Delete tests for removed features

    Available both locally on demand and automatically on pull requests via the GitHub App.

    Continue reading below for detailed usage instructions.
  </Tab>

  <Tab title="Angular, Svelte, Vue & Others">
    **AI-Assisted Updates with Cursor or Claude Code**

    For Angular, Svelte, Vue, and other frameworks (including Nuxt, SvelteKit, Remix, Preact, and more), test updates are handled through AI coding assistants:

    * Use Cursor or Claude Code with Bugster Agent rules
    * AI assistant analyzes your code changes and updates tests accordingly
    * Provides intelligent suggestions for test modifications
    * Works with any framework or routing pattern

    <Card title="Cursor Integration Guide" icon="cube" href="/guides/coding-agents/cursor">
      See the complete setup instructions for using Bugster with Cursor or Claude Code
    </Card>
  </Tab>
</Tabs>

## Usage Modes (Next.js & React)

### Local (manual)

<Note>
  **Available for:** Next.js and React applications with enhanced routing analysis.
</Note>

Run `bugster update` when you're confident about local changes and ready to sync them. The command analyzes **committed changes only** - both staged and unstaged files are ignored. Only differences between commits are considered for test updates.

<CodeGroup>
  ```bash Full update theme={null}
  # Full update (create/modify/delete as needed)
  bugster update
  ```

  ```bash Scope behavior theme={null}
  # Only modify existing tests
  bugster update --update-only

  # Only create new tests
  bugster update --suggest-only

  # Only remove obsolete tests
  bugster update --delete-only
  ```
</CodeGroup>

<Info>
  **Scope flag precedence:** If multiple scope flags are provided, the command will error and ask you to specify only one scope option.
</Info>

### Automatic on Pull Requests

<Note>
  **Available for:** Next.js and React applications with the Bugster GitHub App installed.
</Note>

When you open a Pull Request, Bugster's E2E agent runs `bugster update` first. New commits or force-pushes will **amend the existing Update PR** rather than creating a new one.

<Steps>
  <Step title="Bugster creates an Update PR">
    Bugster opens a secondary PR targeting your feature branch with the suggested test suite changes.
  </Step>

  <Step title="Review the results">
    The original PR gets a comment with the test results and a link to the "Bugster Update PR".
  </Step>

  <Step title="Approve and merge">
    You approve and merge the "Bugster Update PR".
  </Step>

  <Step title="Merge your feature">
    Once the test updates are in, you can merge your feature branch.
  </Step>
</Steps>

<Warning>
  Remember to review the Bugster Update PR **before** merging your feature.
</Warning>

Here is a summary of the flow:

```text theme={null}
You create a PR  →  bugster update runs  →  Bugster opens "Update PR" → 
Bugster comments results in original PR → you review/merge Update PR → merge feature PR
```

## Comparison Baselines (Next.js & React)

Choose the comparison model that fits your development stage:

| Baseline              | Use When                              | Command                                |
| :-------------------- | :------------------------------------ | :------------------------------------- |
| Last commit (default) | Small, isolated edits                 | `bugster update`                       |
| Default branch        | Before PR / comprehensive sweep       | `bugster update --against-default`     |
| Since last update     | Tight inner loop without reprocessing | `bugster update --against-last-update` |

### Last commit (default)

*When to use: Small, isolated edits*

```bash theme={null}
bugster update
```

**Scope:** Compares your latest commit against the previous commit. Only sees files changed in your most recent commit.

### Against default branch

*When to use: Before PR / comprehensive sweep*

```bash theme={null}
bugster update --against-default
```

**Scope:** Compares your current branch against the merge-base with the default branch (e.g., `main`). Sees all changes in your feature branch.

### Since last update

*When to use: Tight inner loop without reprocessing*

```bash theme={null}
bugster update --against-last-update
```

**Scope:** Compares changes since the last time you ran `bugster update`. The "last update" state is stored in `.bugster/state/last-update-hash` and tracks the commit hash from your previous update.

## Recommended Workflow (Next.js & React)

| Scenario                  | Command                                | Use Case                        |
| :------------------------ | :------------------------------------- | :------------------------------ |
| During active development | `bugster update --against-last-update` | Tight feedback loop             |
| Before opening a PR       | `bugster update --against-default`     | Final, comprehensive sweep      |
| For small, isolated edits | `bugster update`                       | Default mode usually sufficient |

## Workflow for Other Frameworks

For Angular, Svelte, Vue, and other frameworks:

| Scenario            | Approach                                           | Use Case                                       |
| :------------------ | :------------------------------------------------- | :--------------------------------------------- |
| Test updates needed | Use Cursor or Claude Code with Bugster Agent rules | AI-assisted test updates based on code changes |
| Review and refine   | AI coding assistant + manual review                | Ensure tests match your changes                |
| Commit test changes | Standard git workflow                              | Keep tests in sync with code                   |

## Examples (Next.js & React)

Here are common scenarios and the commands to use for Next.js and React applications.

<AccordionGroup>
  <Accordion title="Default update for recently touched files">
    ```bash theme={null}
    # Create/modify/delete as needed for just-touched files
    bugster update
    ```
  </Accordion>

  <Accordion title="Full branch comparison before creating a PR">
    ```bash theme={null}
    # Full branch comparison before PR
    bugster update --against-default
    ```
  </Accordion>

  <Accordion title="Tight inner loop without reprocessing old changes">
    ```bash theme={null}
    # Tight inner loop; don't reprocess old changes
    bugster update --against-last-update
    ```
  </Accordion>

  <Accordion title="Limit to modifications only (no new/deleted tests)">
    ```bash theme={null}
    # Limit to modifications only (no new/deleted tests)
    bugster update --update-only
    ```
  </Accordion>

  <Accordion title="Generate suggestions for new areas only">
    ```bash theme={null}
    # Generate suggestions for new areas only
    bugster update --suggest-only
    ```
  </Accordion>

  <Accordion title="Purge tests tied to removed features">
    ```bash theme={null}
    # Purge tests tied to removed features
    bugster update --delete-only
    ```
  </Accordion>

  <Accordion title="Combine scope and baseline">
    ```bash theme={null}
    # Combine scope + baseline
    bugster update --against-default --update-only
    ```
  </Accordion>
</AccordionGroup>

## Review Tips

<Tip>
  **For Next.js & React:**

  * Always review the Update PR diff before merging.
  * Keep descriptive commit messages (e.g., `bugster: update tests for billing portal flow`).
  * If a change looks incorrect, adjust the code or the test, rerun `bugster update`, and re-review.

  **For Angular, Svelte, Vue & Others:**

  * Review AI-generated test updates in your coding assistant.
  * Ensure tests accurately reflect your code changes.
  * Commit test updates alongside your feature changes.
</Tip>

## Summary

**Next.js & React**: Use the `bugster update` command to keep your test suite aligned with code changes—locally or automatically on every PR.

**Angular, Svelte, Vue & Others**: Use AI-assisted updates with Cursor or Claude Code Agent rules for intelligent test synchronization.
