[Tests] Refactor Notifier tests to use real filesystem#7451
[Tests] Refactor Notifier tests to use real filesystem#7451gonzaloriestra wants to merge 1 commit into
Conversation
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.
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
This PR improves the test suite for the
Notifierutility in@shopify/themeby replacing brittle filesystem mocks with real filesystem interactions using temporary directories. This aligns with our goal of making tests more trustworthy and reliable.Changes:
packages/theme/src/cli/utilities/notifier.test.ts:vi.mock('fs/promises').inTemporaryDirectory.readFile.atimeandmtimeupdates usingstatfromnode:fs/promises.beforeEachblock withvi.restoreAllMocks().writeFilefailure by creating a directory at the expected file path, avoiding the need for manual filesystem mocks.Verification:
pnpm --filter @shopify/theme vitest run src/cli/utilities/notifier.test.ts- Passed.@shopify/themepackage - Passed.pnpm nx lint theme,pnpm nx type-check theme, andpnpm knip.PR created automatically by Jules for task 14554694789806569917 started by @gonzaloriestra