Repository navigation
test(helpers): add assertPackageMetadata conformance helper (SW-039) - #283
Merged
dDevAhmed merged 1 commit intoOct 20, 2026
Merged
Conversation
- Add tests/helpers/package-metadata.ts with readPackageJson and assertPackageMetadata, centralising all generated package.json assertions: name, scripts (exact keys + values), engines.node, absence of dependencies/devDependencies, and no embedded secrets. - Export both helpers and their types from tests/helpers/index.ts. - Adopt the helper across all tests in basic-app-package-metadata.test.ts, removing the per-test readFileSync/JSON.parse boilerplate. - Add a consolidated 'conforms to all frozen package.json metadata constraints' test that exercises every check in a single call. - Include src/diagnostics/bounds.ts (previously untracked but already imported by src/diagnostics/run.ts) to keep the build coherent. - Add changeset entry for the patch-level helper addition. No production generator behaviour is changed.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Summary
Add a reusable
assertPackageMetadatatest helper that centralises all generated-projectpackage.jsonconformance assertions, eliminating the per-testreadFileSync/JSON.parseboilerplate that was duplicated across template tests.Changes
New file —
tests/helpers/package-metadata.tsreadPackageJson(path)— reads and parses apackage.json, throwing a descriptive error on missing file or invalid JSON.assertPackageMetadata(path, options)— single call that asserts all seven conformance constraints:namematches the expected project name.scriptsvalues match exactly (no missing or extra keys).engines.nodematches the frozen minimum version.dependenciesis absent (opt-out viaallowDependencies).devDependenciesis absent (opt-out viaallowDevDependencies).SECRET,SEED, orPRIVATE_KEYliterals.ExpectedScriptsandPackageMetadataOptionstypes exported for template tests.tests/helpers/index.tsassertPackageMetadata,readPackageJson,ExpectedScripts, andPackageMetadataOptions.tests/basic-app-package-metadata.test.tsassertPackageMetadata— duplicate read/parse boilerplate removed.'conforms to all frozen package.json metadata constraints'exercises every check in a single call.src/diagnostics/bounds.tssrc/diagnostics/run.ts. Included to keep the build coherent; no SW-039 logic..changeset/sw-039-metadata-conformance-helper.mdAcceptance Criteria
basic-app-package-metadata.test.ts) adopts the helper.npx vitest run tests/basic-app-package-metadata.test.ts).Closes #141
Closes #130
Closes #142