@@ -59,7 +59,8 @@ playdoh-server/config := (dirname: String, opts?: {
5959 argv?: Array<String>,
6060 dc?: String,
6161 blackList?: Array<String>,
62- env?: Object<String, String>
62+ env?: Object<String, String>,
63+ seed?: Object<String, Any>
6364}) => {
6465 get: (keypath?: String) => Any,
6566 set: (keypath: String, value: Any) => void,
@@ -101,6 +102,7 @@ Below are the sources it reads in order of least precendence.
101102 - a object literal based on command line arguments. i.e. if
102103 you pass ` --foo='bar' --bar.baz='bob' ` you will get
103104 ` { "foo": "bar", "bar": { "baz": "bob" } } `
105+ - a seed object of manual overwrites for testing purposes.
104106
105107The config loader also uses ` config-chain ` for the actual
106108 loading logic so you can read [ their docs] [ config-chain ]
@@ -182,6 +184,21 @@ If you prefer to not have this variable configured through
182184 the environment or want to call it something else then you
183185 can pass in ` { NODE_ENV: whatever } ` as ` opts.env `
184186
187+ #### ` opts.seed `
188+
189+ ` opts.seed ` is optional, it can be set to an object
190+
191+ If it exists we will merge the seed object into the config
192+ data we have fetched. seed overwrites all the other sources
193+ of configuration.
194+
195+ The ` seed ` option is very useful for testing purposes, it allows
196+ you to overwrite the configuration that your application would
197+ load with test specific properties.
198+
199+ This is an alternative to the ` NODE_ENV=test ` pattern, we highly
200+ recommend that you do not have a ` test.json ` file at all.
201+
185202#### ` var value = config.get(keypath) `
186203
187204` config.get(keypath) ` will return the value at a keypath. The
0 commit comments