Skip to content

[Tests] Replace mocks with behavior-based testing in fs.test.ts#7497

Merged
gonzaloriestra merged 2 commits intomainfrom
tester-refactor-fs-test-4717222672129663433
May 8, 2026
Merged

[Tests] Replace mocks with behavior-based testing in fs.test.ts#7497
gonzaloriestra merged 2 commits intomainfrom
tester-refactor-fs-test-4717222672129663433

Conversation

@gonzaloriestra
Copy link
Copy Markdown
Contributor

@gonzaloriestra gonzaloriestra commented May 8, 2026

WHY are these changes introduced?

The current test suite in packages/cli-kit/src/public/node/fs.test.ts relies heavily on mocking internal libraries like fast-glob and os, which leads to tests that assert on implementation details (e.g., "was this function called with these arguments") rather than actual behavior (e.g., "did the function find the correct files").

WHAT is this pull request doing?

  • Removed top-level mocks for fast-glob, os, and array in packages/cli-kit/src/public/node/fs.test.ts.
  • Refactored glob tests to create real files in a temporary directory and verify the results.
  • Refactored generateRandomNameForSubdirectory tests to use vi.spyOn for targeted mocking of the reroll logic.
  • Simplified detectEOL tests to use real os.EOL values.
  • Cleaned up redundant vi.doMock calls.

How to test your changes?

CI

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've considered analytics changes to measure impact
  • The change is user-facing — No (it's a test-only change)

PR created automatically by Jules for task 4717222672129663433 started by @gonzaloriestra

Refactored `packages/cli-kit/src/public/node/fs.test.ts` to remove brittle
implementation-focused mocks and replace them with robust, behavior-based
tests using real temporary directories.

- Removed global mocks for `fast-glob`, `os`, and `array`.
- Refactored `glob` tests to verify actual file discovery.
- Refactored `generateRandomNameForSubdirectory` reroll logic tests using `vi.spyOn`.
- Simplified `detectEOL` assertions.
- Removed redundant `vi.doMock` for `fast-glob`.
@google-labs-jules
Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@github-actions github-actions Bot added the no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users. label May 8, 2026
@gonzaloriestra gonzaloriestra added the Jules Created by Jules label May 8, 2026
@gonzaloriestra gonzaloriestra marked this pull request as ready for review May 8, 2026 08:04
@gonzaloriestra gonzaloriestra requested a review from a team as a code owner May 8, 2026 08:04
Comment thread packages/cli-kit/src/public/node/fs.test.ts Outdated
@byrichardpowell byrichardpowell self-requested a review May 8, 2026 11:34
Copy link
Copy Markdown
Contributor

@byrichardpowell byrichardpowell left a comment

Choose a reason for hiding this comment

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

Approving with 1 comment. That way you don't need a second review.

Totally open to the idea the comment I left is not worth addressing.

@gonzaloriestra gonzaloriestra enabled auto-merge May 8, 2026 11:51
@gonzaloriestra gonzaloriestra added this pull request to the merge queue May 8, 2026
Merged via the queue into main with commit 0392ec5 May 8, 2026
28 of 29 checks passed
@gonzaloriestra gonzaloriestra deleted the tester-refactor-fs-test-4717222672129663433 branch May 8, 2026 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Jules Created by Jules no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants