My code includes an if block like this Service: import { isDevMode } from '@angular/core'; export class MyService { constructor() {} methodToTest(): { if (!isDevMode()) { doSomething(); } else { doSomethingDifferentInDevMode(); } } } my-service.spec.ts (the relevant lines only): it('should run doSomething() when isDevMode() returns false', () => { // what should i do here to mock a false value return for isDevMode() ? expect(doSomething).toHaveBeenCalled(); }); How do i spyOn the isDevMode() to make it return false for this single Angular unit test so that i may test that doSomething() is called? Continue reading...