You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix test isolation, fast polling, and cleanup of command tests (#51)
* Fix test isolation, fast polling, and cleanup low-value command tests
Test Isolation:
- Add `credentialsFile` parameter to ResolveConfigOptions and LoadConfigOptions
- Update MobifySource to use credentialsFile when provided (overrides ~/.mobify)
- Add --credentials-file flag with MRT_CREDENTIALS_FILE env var to MrtCommand
- Add config-isolation.ts helper to clear SFCC_*/MRT_* env vars for tests
Fast Polling Tests:
- Use short pollInterval for site-archive tests instead of default 3000ms
- Tests now complete in milliseconds instead of seconds
Command Test Cleanup:
- Delete cartridge-command.test.ts (100% trivial delegation tests)
- Simplify base-command.test.ts (keep getExtraParams, catch tests)
- Simplify instance-command.test.ts (keep requireX, context tests)
- Simplify mrt-command.test.ts (keep requireMrtCredentials only)
- Simplify oauth-command.test.ts (keep parseAuthMethods, requireOAuthCredentials)
- Simplify ods-command.test.ts (keep odsClient lazy init tests)
Documentation:
- Update testing skill with config isolation, pollInterval patterns
- Add command test guidelines (what to test vs avoid)
- Remove general knowledge content (basic Mocha/Chai patterns)
* update lockfile
* Remove upward search from dw.json loading, complete test isolation
- Change loadDwJson() default to look only at ./dw.json (no parent search)
- Update DwJsonSource to use same logic, remove findDwJson import
- Keep findDwJson() exported for users who need explicit upward search
- Set SFCC_CONFIG=/dev/null and MRT_CREDENTIALS_FILE=/dev/null in isolateConfig()
- Update test to verify new behavior (no upward search)
* Wire up isolateConfig to SDK command tests
Add isolateConfig()/restoreConfig() to command test files to ensure
tests are isolated from developer's environment variables (SFCC_*, MRT_*).
Files updated:
- test/cli/base-command.test.ts
- test/cli/instance-command.test.ts
- test/cli/mrt-command.test.ts
- test/cli/oauth-command.test.ts
- test/cli/ods-command.test.ts
* timing issues in tests; don't sleep is poll is 0
* initial wait from poll interval
* Improve command test patterns with Sinon and integration tests
- Add sinon, @types/sinon, @oclif/test as SDK dev dependencies
- Create stubParse helper for cleaner parse method mocking
- Refactor 5 command test files to use Sinon instead of manual mocking
- Add test fixture (test/fixtures/test-cli/) for integration testing
- Add base-command.integration.test.ts with runCommand() tests
- Update testing skill docs with new patterns
The stubParse helper eliminates the brittle MockableXxxCommand type
casting pattern. Integration tests exercise full command lifecycle
through the oclif test utilities.
* Restore CartridgeCommand unit tests with improved coverage
- Add cartridge-command.test.ts with tests for cartridgePath,
cartridgeOptions, provider runner init, and findCartridgesWithProviders
- Use stubParse helper with server mock for instance-dependent tests
- Improves cartridge-command.ts coverage from 19% to 91%
* Add InstanceCommand and MrtCommand integration tests
Integration tests provide API contract validation beyond code coverage:
- Catch flag definition errors (wrong type, missing env var)
- Validate baseFlags inheritance works correctly
- Exercise full oclif command lifecycle (discovery, parse, init, run)
- Test commands the way consumers actually use them
New fixtures:
- test-instance.js: Tests server, instance flags and hasServer check
- test-mrt.js: Tests api-key, project, environment, cloud-origin flags
New integration tests:
- instance-command.integration.test.ts (5 tests)
- mrt-command.integration.test.ts (8 tests)
Total integration tests: 18 (BaseCommand + InstanceCommand + MrtCommand)
* prettier updates
0 commit comments