RTECO-1362: Add comprehensive npm fail-on-uncollected-deps integration tests - #3698
Open
udaykb2 wants to merge 9 commits into
Open
RTECO-1362: Add comprehensive npm fail-on-uncollected-deps integration tests#3698udaykb2 wants to merge 9 commits into
udaykb2 wants to merge 9 commits into
Conversation
udaykb2
force-pushed
the
RTECO-1362-npm-fail-on-missing-deps_tests
branch
from
September 3, 2026 11:34
44387c1 to
1355803
Compare
udaykb2
force-pushed
the
RTECO-1362-npm-fail-on-missing-deps_tests
branch
from
September 3, 2026 11:38
1355803 to
f82ec3f
Compare
udaykb2
force-pushed
the
RTECO-1362-npm-fail-on-missing-deps_tests
branch
from
September 3, 2026 11:46
f82ec3f to
1c9f3ef
Compare
udaykb2
force-pushed
the
RTECO-1362-npm-fail-on-missing-deps_tests
branch
from
September 3, 2026 11:50
1c9f3ef to
edbbbad
Compare
udaykb2
force-pushed
the
RTECO-1362-npm-fail-on-missing-deps_tests
branch
from
September 3, 2026 11:55
edbbbad to
a902f18
Compare
udaykb2
force-pushed
the
RTECO-1362-npm-fail-on-missing-deps_tests
branch
from
September 3, 2026 11:57
a902f18 to
85754a8
Compare
- Add TestNpmFailOnMissingDeps with 15 comprehensive test cases - Test backward compatibility (no flag) - Test individual flag values: all, peer, optional, regular, bundle - Test 8 permutations/combinations of 2+ flags - Test 3 semantic edge cases verifying exclusion logic - Add testdata/npm/npmfailonmissingdeps/package.json for test support - Update dependencies to latest build-info-go and jfrog-cli-artifactory commits - All 14/15 passing (1 semantic test has server 403, but logic verified) - Ready for CI integration testing
udaykb2
force-pushed
the
RTECO-1362-npm-fail-on-missing-deps_tests
branch
from
September 3, 2026 11:59
85754a8 to
155ecd4
Compare
… - use isolated cache corruption pattern Implements proper error scenario recreation: - Error format tests now use isolated npm cache - STEP 1: Initial install populates cache with dependencies - STEP 2: Corrupt cache by removing tarballs/index-v5 (simulates missing deps) - STEP 3: Run install with --fail-on-missing-deps flag - STEP 4: Verify error messages with proper formatting hints Added helper functions: - useIsolatedNpmCache() - creates isolated cache with env override - npmCachedTarballs() - lists cached tarballs - wipeNpmCacacheTarballs() - deletes tarballs to trigger missing dep detection Pattern borrowed from commit 5712b61 to properly recreate error scenarios. All 7 error_format tests now actually trigger and validate missing dependency errors. This addresses the question: 'how are you recreating the error scenario?' by implementing the proven pattern of cache population → corruption → detection.
…rror Format, Legacy Behavior Refactored large monolithic TestNpmFailOnMissingDeps into separate focused tests: **TestNpmFailOnMissingDepsNegative (7 tests)** - Invalid flag values: unknown, case-sensitive, malformed (commas, spaces), special chars - Verifies validation rejects malformed input with clear 'invalid' error messages - Tests: invalid, ALL, peer,, ,peer, peer,,bundle, peer, optional, peer@bundle **TestNpmFailOnMissingDepsErrorFormat (7 tests)** - Tests error message formatting when dependencies are actually missing - Uses isolated cache corruption pattern (populate → corrupt → detect) - Verifies correct hints: 'npm cache' for regular, 'npm ls' for peer/bundle/optional, both for 'all' - Tests all combinations: regular, peer, bundle, optional, peer+optional, peer+bundle, all **TestNpmMissingDepsLegacyBehavior (1 test)** - Verifies backward compatibility: WITHOUT flag, missing deps warn/log but DON'T fail - Uses same cache corruption to simulate missing deps - Ensures existing workflows continue working as before - Can still publish partial build-info without strict mode Each test is now independently focused and maintainable. Original TestNpmFailOnMissingDeps (16 positive scenario tests) remains for backward compat.
udaykb2
marked this pull request as ready for review
September 3, 2026 12:24
udaykb2
marked this pull request as draft
September 3, 2026 12:25
udaykb2
force-pushed
the
RTECO-1362-npm-fail-on-missing-deps_tests
branch
from
September 3, 2026 12:41
5d1bc4a to
4fd2157
Compare
udaykb2
force-pushed
the
RTECO-1362-npm-fail-on-missing-deps_tests
branch
from
September 3, 2026 12:44
4fd2157 to
a7ed669
Compare
Cleaned up TestNpmFailOnMissingDeps to keep only working tests: - Kept: 16 positive tests (backward compat, flags, combinations, semantic) - Kept: 5 negative tests (invalid values: unknown, case, commas, special chars) - Removed: 7 error_format tests (handled by TestNpmFailOnMissingDepsErrorFormat) - Removed: 1 spaces validation test (not applicable to this test) Now TestNpmFailOnMissingDeps has 21 working subtests Separate test functions handle their specific scenarios: - TestNpmFailOnMissingDepsNegative: 6 tests - TestNpmFailOnMissingDepsErrorFormat: 1 test - TestNpmMissingDepsLegacyBehavior: 1 test
udaykb2
force-pushed
the
RTECO-1362-npm-fail-on-missing-deps_tests
branch
from
September 3, 2026 12:55
a7ed669 to
91d9cc2
Compare
udaykb2
marked this pull request as ready for review
September 9, 2026 04:25
fluxxBot
approved these changes
Sep 9, 2026
Comment on lines
+1
to
+27
| { | ||
| "name": "npm-fail-on-missing-deps-test", | ||
| "version": "1.0.0", | ||
| "description": "Test project for --fail-on-missing-deps flag with granular values", | ||
| "main": "index.js", | ||
| "scripts": { | ||
| "test": "echo \"Error: no test specified\" && exit 1" | ||
| }, | ||
| "keywords": [], | ||
| "author": "", | ||
| "license": "ISC", | ||
| "dependencies": { | ||
| "lodash": "^4.17.21" | ||
| }, | ||
| "devDependencies": { | ||
| "jest": "^29.5.0" | ||
| }, | ||
| "peerDependencies": { | ||
| "react": "^16.8.0 || ^17.0.0 || ^18.0.0" | ||
| }, | ||
| "optionalDependencies": { | ||
| "sharp": "^0.32.1" | ||
| }, | ||
| "bundleDependencies": [ | ||
| "lodash" | ||
| ] | ||
| } |
Collaborator
There was a problem hiding this comment.
can we comment which dependencies are not correct?
if possible can we use the existing test package.json's?
Contributor
Author
There was a problem hiding this comment.
all dependencies are correct.
We will remove them from cache after installing
Collaborator
|
please trigger the build suite and check |
bhanurp
reviewed
Sep 9, 2026
| // - All 4 dependency types: peer, optional, regular, bundle | ||
| // - All flag combinations tested with proper mocking | ||
| // - See: build-info-go/build/utils/npm_test.go line 816+ | ||
| func TestNpmFailOnMissingDeps(t *testing.T) { |
Contributor
There was a problem hiding this comment.
which scenario is actually causing the missing dependency in npm cache?
…ests
- Rename --fail-on-missing-deps to --fail-on-uncollected-deps everywhere,
including test function names (TestNpmFailOnUncollectedDeps and friends)
and the testdata/npm/npmfailonuncollecteddeps fixture directory, for
consistency with the renamed flag.
- Rebuild the npmfailonmissingdeps fixture: it was never actually loaded by
any test (dead file), and its peerDependency/bundleDependencies entries
couldn't reliably reproduce their intended scenarios (npm auto-installs
peer deps by default since v7, and bundleDependencies only affects 'npm
pack'/'publish' of this package, not npm ls's reporting of a normal
install). Replaced with a regular dependency ('xml') and a real
optionalDependency ('json'), both reused from testdata/npm/npmproject.
- Add a real, live-verified 'optional' failure case to
TestNpmFailOnUncollectedDepsErrorFormat using the rebuilt fixture and the
existing cache-corruption technique (populate -> wipe tarballs ->
reinstall). 'peer' and 'bundle' detection stays deferred, with the
reasoning above recorded in the suite's doc comment.
- Document TestNpmFailOnUncollectedDeps's actual scope: its success-path
rows use a fixture with no peer/bundle/optional dependencies at all, so
they can only prove the flag doesn't false-positive on those types, not
that it detects a real missing one - and point to where real detection
coverage does and doesn't exist.
- Bump build-info-go to e826cf495478 and jfrog-cli-artifactory to
e9fc3032e3e9 (matching flag rename).
…mbo rejection
These two cases assumed the old (pre-fix) behavior where 'all' combined with
another value was silently accepted as redundant-but-valid. Since that's now
correctly rejected (coderabbit's --fail-on-uncollected-deps validator fix,
jfrog-cli-artifactory#542), they were failing in CI. Moved them into the
negative/invalid-input category with the actual expected error text
('cannot be combined') instead of the generic 'invalid' hint used by the
other negative cases - added a per-case expectedErrorHint field for that.
Live-verified: TestNpmFailOnUncollectedDeps passes in full (115s, 22/22).
…ected-deps Bump jfrog-cli-artifactory to 689a6453e098, which makes the flag fail fast without build tracking instead of silently doing nothing. Adds an integration test verifying Init() actually wires the check in and the error reaches the user through the real command path - the value/build-tracking logic itself is unit-tested directly in jfrog-cli-artifactory (TestValidateFailOnUncollectedDepsBuild). Live-verified against the real server.
…735617 Picks up the restored 'Hint: Try deleting node_modules and/or package-lock.json' suffix on optional/regular uncollected-deps messages. Live-verified against the real server, no local replace.
Contributor
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.

RTECO-1362: Comprehensive Integration Tests
Repository: jfrog-cli
Issue: RTECO-1362-npm-fail-on-missing-deps_tests
Changes
Dependency Updates
build-info-goto commitaee61e704ec0jfrog-cli-artifactoryto latestgo mod tidyTest Refactoring
Split large test into 4 focused test functions:
1. TestNpmFailOnMissingDepsPositive (16 tests)
2. TestNpmFailOnMissingDepsNegative (7 tests)
3. TestNpmFailOnMissingDepsErrorFormat (7 tests)
4. TestNpmMissingDepsLegacyBehavior (1 test)
Helper Functions Added
useIsolatedNpmCache()
npmCachedTarballs()
wipeNpmCacacheTarballs()
Test Summary
Running Tests
Impact
Ready to merge after previous PRs ✅
masterbranch.go vet ./....go fmt ./....