GitHub 6521★

Check if the code is running in Jest

JavaScript version

const isRunningInJest = typeof process !== 'undefined' && process.env.JEST_WORKER_ID !== undefined;

TypeScript version

const isRunningInJest: boolean = typeof process !== 'undefined' && process.env.JEST_WORKER_ID !== undefined;
Follow me on and to get more useful contents.