test: add unit tests for project-utils utility functions#3322
Open
yogeshwaran-c wants to merge 1 commit intonestjs:masterfrom
Open
test: add unit tests for project-utils utility functions#3322yogeshwaran-c wants to merge 1 commit intonestjs:masterfrom
yogeshwaran-c wants to merge 1 commit intonestjs:masterfrom
Conversation
Add comprehensive test coverage for all pure utility functions exported from lib/utils/project-utils.ts, which previously had no test coverage. The new test suite covers: - shouldAskForProject: 9 tests covering all schematic types (app, sub-app, library, lib) and edge cases (undefined/empty projects, appName provided) - shouldGenerateSpec: 8 tests covering CLI priority, boolean config, schematic-specific config, project-specific config, and global fallback behavior - shouldGenerateFlat: 4 tests covering CLI priority and configuration fallback - getSpecFileSuffix: 4 tests covering CLI priority, configuration value, and default "spec" fallback - moveDefaultProjectToStart: 5 tests covering project reordering, null projects, sourceRoot-based filtering, and defaultLabel stripping - hasValidOptionFlag: 8 tests covering boolean/string matching, missing options, and empty arrays Total: 38 new passing tests.
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.
What kind of change does this PR introduce?
Test coverage improvement.
What is the current behavior?
The
lib/utils/project-utils.tsfile exports 6 utility functions that are used across multiple actions (generate, build, start) but has zero test coverage. These functions handle critical logic around:What is the new behavior?
Adds a comprehensive test suite (
test/lib/utils/project-utils.spec.ts) with 38 unit tests covering all 6 exported functions:shouldAskForProjectshouldGenerateSpecspecPassedAsInput), boolean config, schematic-specific config objects, project-level fallback to global configshouldGenerateFlatgetSpecFileSuffixmoveDefaultProjectToStarthasValidOptionFlagAll 38 tests pass. No existing tests are affected.
Additional context
extra-args-warning.spec.tsandget-value-or-default.spec.tsjest-config.jsonconfiguration