Skip to content

[Tests] Refactor Notifier tests to use real filesystem#7451

Closed
gonzaloriestra wants to merge 1 commit into
mainfrom
tester-notifier-fs-refactor-14554694789806569917
Closed

[Tests] Refactor Notifier tests to use real filesystem#7451
gonzaloriestra wants to merge 1 commit into
mainfrom
tester-notifier-fs-refactor-14554694789806569917

Conversation

@gonzaloriestra

Copy link
Copy Markdown
Contributor

This PR improves the test suite for the Notifier utility in @shopify/theme by replacing brittle filesystem mocks with real filesystem interactions using temporary directories. This aligns with our goal of making tests more trustworthy and reliable.

Changes:

  • Refactored packages/theme/src/cli/utilities/notifier.test.ts:
    • Removed global vi.mock('fs/promises').
    • Wrapped filesystem-dependent tests in inTemporaryDirectory.
    • Added assertions to verify actual file content using readFile.
    • Added assertions to verify atime and mtime updates using stat from node:fs/promises.
    • Improved test cleanup by adding a beforeEach block with vi.restoreAllMocks().
    • Refactored the error handling test to simulate a writeFile failure by creating a directory at the expected file path, avoiding the need for manual filesystem mocks.

Verification:

  • Ran pnpm --filter @shopify/theme vitest run src/cli/utilities/notifier.test.ts - Passed.
  • Ran all unit tests for @shopify/theme package - Passed.
  • Verified package integrity with pnpm nx lint theme, pnpm nx type-check theme, and pnpm knip.

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

Replaced brittle filesystem mocks in `notifier.test.ts` with real filesystem operations using `inTemporaryDirectory`.
This makes the tests more trustworthy and better aligns with the project's testing standards.

Key changes:
- Removed `vi.mock('fs/promises')`.
- Used `inTemporaryDirectory` for tests interacting with the filesystem.
- Verified actual file content and timestamp updates.
- Improved test isolation with `vi.restoreAllMocks()`.
- Simulated filesystem errors deterministically by creating directory conflicts.
@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 4, 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