import { CommonService } from './common.service'; import { TestBed } from '@angular/core/testing'; const env = { production: true }; describe('CommonService', () => { let service: CommonService; beforeEach(() => TestBed.configureTestingModule({providers: [ { provide: 'env', useValue: env }, // CommonService, user providedIn: root ]})); beforeEach(() => { service = TestBed.get(CommonService); }); it('should be created', () => { expect(service).toBeTruthy(); }); it('getEnv should Should be able to use', () => { const ans = service.getEnv(); expect(ans).toBeTruthy(); console.log(ans); }); });