Actually you need not just create a spy but also execute it to increase coverage. A spy replaces the spied function with a stub. If you want this spy function to be called normally, you need to add .and.callThrough() to your spy.
spyOn(EnvironmentService, 'isProduction').and.callThrough()
You can also read more here: about spy and callThrough
Answer from Tatsiana on Stack OverflowNot able to increase code coverage in Angular Unit testing - Stack Overflow
angular - How do I get hundred percent code coverage with my unit testing on this component and access the else part? - Stack Overflow
angular - How to increase code coverage to 80 percentage in Jasmine test case - Stack Overflow
angular5 - How to implement code coverage for angular 5? - Stack Overflow
Videos
Actually you need not just create a spy but also execute it to increase coverage. A spy replaces the spied function with a stub. If you want this spy function to be called normally, you need to add .and.callThrough() to your spy.
spyOn(EnvironmentService, 'isProduction').and.callThrough()
You can also read more here: about spy and callThrough
spyOn(EnvironmentService, 'isProduction'); overwrites the service method and then EnvironmentService.isProduction(); is calling a spy instead of your method. Thus your method isn't called. valid test would be removing spy and will looke in some way like expect(EnvironmentService.isProduction()).toBe(false)