I try to write a UT for a service in Angular.
The Service will look like this
@Injectable()
export class TimeZoneStateService {
constructor(
@Optional()
@Inject(GLOBAL_CONFIG)
private config?: ViewConfig,
) {}
}
and the UT
import { TestBed } from '@angular/core/testing';
import {
GLOBAL_CONFIG,
TimeZoneStateService,
} from '@sdo/givs-common-service';
describe('TimeZoneStateService', () => {
let service: TimeZoneStateService;
beforeEach(() => {
TestBed.configureTestingModule({
providers: [
TimeZoneStateService,
{
provide: GLOBAL_CONFIG,
useValue: {
timeZoneResolver: () => 'America/Toronto',
},
},
],
});
service = TestBed.createComponent(TimeZoneStateService).componentInstance;
});
it('should be created', () => {
expect(service).toBeTruthy();
});
)
the error message when I run the UT is
enter image description here
I try to pass the UT, and don’t know why the have such error
New contributor
John Mai is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.