Skip to content

[Tests] Refactor Notifier tests to remove filesystem mocks#7449

Draft
gonzaloriestra wants to merge 1 commit intomainfrom
refactor-notifier-test-filesystem-mock-2324320246412902882
Draft

[Tests] Refactor Notifier tests to remove filesystem mocks#7449
gonzaloriestra wants to merge 1 commit intomainfrom
refactor-notifier-test-filesystem-mock-2324320246412902882

Conversation

@gonzaloriestra
Copy link
Copy Markdown
Contributor

Summary

Refactored packages/theme/src/cli/utilities/notifier.test.ts to remove fs/promises mocks in favor of using inTemporaryDirectory and real filesystem interactions.

Why

Following the "Tester" philosophy, real filesystem interactions in temporary directories are preferred over mocking node:fs to ensure tests are deterministic, more trustworthy, and better-aligned with actual behavior.

Changes

  • Removed vi.mock('fs/promises') from packages/theme/src/cli/utilities/notifier.test.ts.
  • Wrapped filesystem-dependent tests in inTemporaryDirectory.
  • Replaced mock call assertions (expect(fs.writeFile).toHaveBeenCalledWith(...)) with actual file content assertions (expect(await readFile(path)).toEqual(...)).
  • Updated the error path test to use a real directory path as an "invalid" file path to trigger a natural filesystem error.

Verification

  • Ran pnpm --filter @shopify/theme vitest run src/cli/utilities/notifier.test.ts (All 7 tests passed).
  • Ran pnpm --filter @shopify/theme lint (Passed).
  • Ran pnpm --filter @shopify/theme type-check (Passed).
  • Ran all unit tests in @shopify/theme package via pnpm --filter @shopify/theme vitest run (All 566 tests passed).

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

Refactored `packages/theme/src/cli/utilities/notifier.test.ts` to use `inTemporaryDirectory` and real filesystem operations instead of mocking `fs/promises`.
Updated test assertions to verify actual file contents, ensuring behavior-driven testing rather than implementation-focused mock assertions.
@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 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

1 participant