universal-config
universal-config copied to clipboard
Add support for test env config
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.