Automatic tests use the --disable-cli-modules flag and the --additional-module-paths specifying cli modules. This reuslts however in the cli modules not being loaded (and thus the test failing for modules which depend on those cli).
When running the same test command without the --disable-cli-modules this error doesn’t occur.
--disable-cli-modules slightly decreases Slicer startup time, so it is useful for tests that don’t need CLI modules. If your test requires CLI modules then separate tests could be added, but maybe it would be nicer to add an option (TESTING_WITH_CLI or something similar) to slicerMacroBuildScriptedModule in SlicerMacroBuildScriptedModule.cmake to not disable CLI modules for tests.