Fix template example sync when using --update-snapshots#231
Open
iclanton wants to merge 4 commits intoSharePoint:mainfrom
Open
Fix template example sync when using --update-snapshots#231iclanton wants to merge 4 commits intoSharePoint:mainfrom
iclanton wants to merge 4 commits intoSharePoint:mainfrom
Conversation
In UPDATE_MODE, scaffold to temp dir then sync to examples: copy new/modified files and delete removed files using the same filter logic. Previously, scaffolding directly into the examples directory left stale files behind when template files were removed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…el reads Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes snapshot update behavior in tests/spfx-template-test so that heft test --update-snapshots no longer leaves stale files behind when templates remove files, by scaffolding into a temp directory and syncing results back into examples/.
Changes:
- Always scaffold templates into a temp output folder (instead of sometimes scaffolding directly into
examples/). - In
--update-snapshotsmode, sync temp output toexamples/by copying scaffolded files and deleting files no longer produced. - Refactor directory traversal/comparison helpers (async generator traversal, centralized ignore filtering, concurrent I/O via
Async.forEachAsync).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/spfx-template-test/src/tests/templates.test.ts | Implements temp-dir scaffolding + update-mode sync logic; refactors traversal/filtering and parallelizes I/O. |
| tests/spfx-template-test/src/tests/constants.ts | Adds PROJECT_ROOT for package-local temp output pathing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fixes a crash when running with --update-snapshots for a template that has no corresponding example directory yet (new template being added). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Description
Fixes a bug in
tests/spfx-template-testwhere runningheft test --update-snapshotsdid not correctly sync removed files from template output back to the examples directory.Previously, update mode scaffolded directly into the examples directory, which meant files removed from a template were left behind as stale files. The fix scaffolds to a temp directory (same as normal mode) and then syncs the result to the examples directory — copying new/modified files and deleting files no longer produced by the template — while leaving gitignored paths (e.g.
node_modules,lib) untouched.Normal mode (without
--update-snapshots) already correctly detected all three change types (added, modified, removed) via file list and content comparison; this was only a bug in update mode.Also includes refactors: async generator for directory traversal, module-level filter constants, and
Async.forEachAsyncfor concurrent file I/O.How was this tested?
Modified a file in an example project and renamed a different file (covering modification, deletion, and addition).
heft testfailed as expected for all three change types, andheft test -ucorrectly restored the examples directory.Type of change