[Tests] Refactor Notifier tests to remove filesystem mocks#7449
[Tests] Refactor Notifier tests to remove filesystem mocks#7449gonzaloriestra wants to merge 1 commit intomainfrom
Conversation
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.
|
👋 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. |
Summary
Refactored
packages/theme/src/cli/utilities/notifier.test.tsto removefs/promisesmocks in favor of usinginTemporaryDirectoryand real filesystem interactions.Why
Following the "Tester" philosophy, real filesystem interactions in temporary directories are preferred over mocking
node:fsto ensure tests are deterministic, more trustworthy, and better-aligned with actual behavior.Changes
vi.mock('fs/promises')frompackages/theme/src/cli/utilities/notifier.test.ts.inTemporaryDirectory.expect(fs.writeFile).toHaveBeenCalledWith(...)) with actual file content assertions (expect(await readFile(path)).toEqual(...)).Verification
pnpm --filter @shopify/theme vitest run src/cli/utilities/notifier.test.ts(All 7 tests passed).pnpm --filter @shopify/theme lint(Passed).pnpm --filter @shopify/theme type-check(Passed).@shopify/themepackage viapnpm --filter @shopify/theme vitest run(All 566 tests passed).PR created automatically by Jules for task 2324320246412902882 started by @gonzaloriestra