In utils/Config/__tests__/config.test.ts, we performed "integration" tests to make sure an entire YAML can be serialized, and an entire Config instance can be de-serialized to YAML.
For example, in the test for configToYaml(), we directly test if a Config object can serialize to an expected YAML string.
This is not optimal because configToYaml() calls settingsToYamlObj() internally (a dependency of configToYaml()), such that if settingsToYamlObj() is implemented incorrectly, then that test case must fail.
Solution
We should mock the dependency utility functions (e.g. settingsToYamlObj() in configToYaml()) to test that they have been invoked.
Description
In
utils/Config/__tests__/config.test.ts
, we performed "integration" tests to make sure an entire YAML can be serialized, and an entireConfig
instance can be de-serialized to YAML.For example, in the test for
configToYaml()
, we directly test if aConfig
object can serialize to an expected YAML string.This is not optimal because
configToYaml()
callssettingsToYamlObj()
internally (a dependency ofconfigToYaml()
), such that ifsettingsToYamlObj()
is implemented incorrectly, then that test case must fail.Solution
We should mock the dependency utility functions (e.g.
settingsToYamlObj()
inconfigToYaml()
) to test that they have been invoked.