Skip to content

test(e2e): refactor browser snapshot tests for better isolation#913

Merged
fi3ework merged 1 commit intomainfrom
bes2
Jan 28, 2026
Merged

test(e2e): refactor browser snapshot tests for better isolation#913
fi3ework merged 1 commit intomainfrom
bes2

Conversation

@fi3ework
Copy link
Copy Markdown
Member

Summary

  • Refactor e2e/browser-mode/snapshot.test.ts to use temporary fixtures
  • Use prepareFixtures to copy test files to a non-tracked directory before execution
  • Implement treeKill in afterEach to ensure clean process termination
  • Use runBrowserCliWithCwd to execute tests in the isolated temporary directory
  • Remove manual restoration of tracked test files in afterEach

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings January 28, 2026 06:00
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @fi3ework, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the reliability and isolation of browser-mode snapshot tests. By transitioning to temporary test fixtures and implementing robust process termination, it ensures that test runs do not interfere with each other or leave behind residual processes or modified files, particularly addressing issues with file locking on Windows.

Highlights

  • Test Isolation with Temporary Fixtures: The snapshot tests now utilize temporary fixture directories, copied via prepareFixtures, ensuring that each test run operates in an isolated environment and does not modify or depend on shared files.
  • Robust Process Termination: Implemented treeKill in the afterEach hook to reliably terminate the CLI process and any child processes (e.g., browser instances). This prevents orphaned processes and addresses potential file locking issues, especially on Windows.
  • Streamlined Test Execution: Introduced a new runSnapshot helper function that wraps runBrowserCliWithCwd, ensuring all snapshot tests execute within their respective temporary working directories, enhancing consistency and reliability.
  • Elimination of Manual Cleanup: Removed the manual restoration of test files (update.test.ts, inlineUpdate.test.ts) in afterEach, as the new temporary fixture approach automatically handles cleanup by deleting the entire temporary directory.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request significantly improves the e2e snapshot tests by refactoring them to use temporary fixtures. This makes the tests more robust and isolated, which is a great improvement. The use of prepareFixtures and cleaning up in afterEach is a solid pattern. I've added a couple of suggestions to further enhance the test cleanup logic for better reliability and type safety. Overall, this is a high-quality contribution.

Comment on lines +47 to +48
treeKill(pid, 'SIGKILL');
await new Promise((resolve) => setTimeout(resolve, 2000));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using setTimeout with a fixed duration can make tests slower and potentially flaky. The tree-kill library provides a callback that is executed once the process tree is killed. Using this callback is more reliable and avoids the arbitrary wait.

      await new Promise<void>((resolve) => {
        treeKill(pid, 'SIGKILL', () => {
          // The callback is called when the process tree has been killed or if an error occurred.
          // We resolve here to ensure cleanup continues.
          resolve();
        });
      });

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the browser mode snapshot tests to use temporary fixtures, ensuring better test isolation and preventing file conflicts on Windows.

Changes:

  • Refactors snapshot tests to use prepareFixtures for creating temporary, isolated test fixtures
  • Implements process cleanup with treeKill in afterEach to prevent file lock issues on Windows
  • Replaces direct runBrowserCli calls with runBrowserCliWithCwd to execute tests in temporary directories

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@fi3ework fi3ework changed the title fix(e2e): ensure environment variables are truly unset in CLI helper test(e2e): refactor browser snapshot tests for better isolation Jan 28, 2026
- Refactor `e2e/browser-mode/snapshot.test.ts` to use temporary fixtures
- Use `prepareFixtures` to copy test files to a non-tracked directory before execution
- Implement `treeKill` in `afterEach` to ensure clean process termination
- Use `runBrowserCliWithCwd` to execute tests in the isolated temporary directory
- Remove manual restoration of tracked test files in `afterEach`
@fi3ework fi3ework enabled auto-merge (squash) January 28, 2026 06:24
@fi3ework fi3ework merged commit 41f9365 into main Jan 28, 2026
9 checks passed
@fi3ework fi3ework deleted the bes2 branch January 28, 2026 06:26
@fi3ework fi3ework mentioned this pull request Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants