Skip to content

Latest commit

 

History

History
17 lines (13 loc) · 406 Bytes

check-if-the-code-is-running-in-jest.mdx

File metadata and controls

17 lines (13 loc) · 406 Bytes
category created title
Misc
2022-06-18
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;