A utility for executing code under a specific NODE_ENV.
$ yarn add @shopify/with-envOr, if you just need this for tests:
$ yarn add --dev @shopify/with-envIn this example, we are testing some code using Jest. Note that, while Jest is not required to use @shopify/with-env, it is our recommended testing framework for node and javascript applications.
import withEnv from '@shopify/with-env';
it('does one thing in development', () => {
withEnv('development', () => {
// your code here
});
});
it('does another thing in production', () => {
withEnv('production', () => {
// your code here
});
});