Repository navigation
[Tests] Verify theme check initConfig against real config files - #8870
Draft
github-actions[bot] wants to merge 1 commit into
Draft
github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
The initConfig tests replaced @shopify/cli-kit/node/fs with stubs and asserted writeFile was called with expect.any(String), so neither the file nor its contents were ever checked. Use a real temporary directory and assert the written YAML and the existing-file guard instead. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WHY are these changes introduced?
The
initConfigtests inpackages/theme/src/cli/services/check.test.tsreplaced the whole@shopify/cli-kit/node/fsmodule with stubs:They then asserted only that
writeFilehad been called withexpect.any(String). Nothing checked that a config file was created, what it contained, or that an existing file survived — so the tests passed as long asinitConfigcalledwriteFilewith any string at all. That also conflicts with the repository rule that filesystem tests must use real temporary files.I reviewed the Main tests runs created between 2026-10-06T00:30Z and 2026-10-13T00:30Z first. The only failure in that window was
app-security-commands.test.ts > formatAppSecurityCommand > the PowerShell record command reads a findings file without a byte order mark as UTF-8 in Windows PowerShell 5.1, which timed out at 13s in [Main] Node 24.1.0 in windows-latest. That flake already has an open fix in #8832, so there was no actionable, unaddressed flake left and I picked this quality issue instead.WHAT is this pull request doing?
Drops the
fsmodule mock fromcheck.test.tsand runs bothinitConfigtests in a real temporary directory viainTemporaryDirectory:.theme-check.ymlfirst, then asserts the file is byte-for-byte unchanged and thatloadConfigwas never consulted, rather than assertingwriteFilewas not called.extends: theme-check:recommended, thenode_modules/**ignore entry, and the commented-out check settings — rather thanexpect.any(String).Coverage is preserved and tightened: the
outputInfo/outputSuccessmessage assertions stay, and the contents assertion is new. TheloadConfigstub remains because it reads the installed theme-check settings, which are not what these tests are about;fsis no longer mocked at all, so the rest of the file is unaffected. This removes the lastfsautomatic mock in the theme package, which the rule added in #8866 does not cover because this one is a factory mock.Both tests were confirmed to fail without the behavior they assert. Replacing
writeFile(filePath, ${initConfigYml}${checksYml})withwriteFile(filePath, initConfigYml)fails the creation test, and removing thefileExistsearly return fails the existing-file test; the old assertions passed in both cases. Validation on Linux Node 26.1.0: the file passes (17 tests), three times under--sequence.shuffle, under--pool=forks, and alongside all 18packages/theme/src/cli/servicestest files (163 passed) including shuffled.nx type-check themeand ESLint on the changed file both pass. These tests are not platform-gated and the assertions avoidwriteFileEOL translation and usejoinPath, so they should behave the same on Windows and macOS, but I could not run those platforms locally.How to manually test your changes?
Checklist
patchfor bug fixes ·minorfor new features ·majorfor breaking changes) and added a changeset withpnpm changeset add