universal-config icon indicating copy to clipboard operation
universal-config copied to clipboard

Add support for test env config

Open joshwcomeau opened this issue 7 years ago • 0 comments

Hi Naoufal 👋

Hope everything's been going well with you!

At Unsplash, we're in the process of adding snapshot tests with Jest. An issue we've run into is that the snapshots change when you change the environment you're connected to (eg. switching from staging to prod in dev.js changes the UNSPLASH_API_URL).

Our solution is to add yet another environmental-dependent config, so that we can specify static values for the test environment, that won't change when we change our dev config.

My first thought was to add a catch-all, that would load a file named after the environment, but then I remembered that in Node, require statements can't be dynamic. As a result, I had to just add another condition to the getLocalOverrides method.

No worries if you feel like this addition is too 'niche' for this project. I opened a PR in case you found it useful, but if not we can just use our fork.

joshwcomeau avatar Mar 09 '17 19:03 joshwcomeau