Skip to content

Instantly share code, notes, and snippets.

View texas2010's full-sized avatar

Tex texas2010

View GitHub Profile
@phatnguyenuit
phatnguyenuit / getAssetPath.test.ts
Created October 10, 2021 03:01
Mock process.env in Jest - full example
import getAssetPath from './getAssetPath';
describe('getAssetPath', () => {
const originalEnv = process.env;
describe.each`
nodeEnv | expectedPath
${'production'} | ${'/production-path'}
${'development'} | ${'/development-path'}
${'test'} | ${'/development-path'}
`('when process.env.NODE_ENV="$nodeEnv"', ({ nodeEnv, expectedPath }) => {