zowe-cli
zowe-cli copied to clipboard
[v2] Command handler unit tests require a lot of mocks
In a unit test that calls ICommandHandler.process
and mocks an ImperativeConfig.instance.config
object with the exists: true
property defined, several mocks are required which may be an inconvenience for plug-in developers.
For an example, see this sample plug-in unit test: https://github.com/zowe/zowe-cli-sample-plugin/commit/a6b6d22ea06dcdc313e3ca5a341d0769e7e5301b#diff-c5dfd517fddad71ab1fe78c762be9a365f981aa118a4b3a72427717d679d634c
The following functions require mocks to be defined on the ImperativeConfig instance:
-
LoggerUtils.censorRawData
-envVariablePrefix
,config.api.layers.get
,config.api.secure.secureFields
-
ConfigAutoStore.findActiveProfile
-loadedConfig.profiles
After a short discussion, we wanted to reduce code duplication. This might be a good enhancement for the cli-test-utils package. We could add a few clever ways to mock these methods 😋 (not a good first issue 😅 )