You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We started using the very nice ng-mocks for our test, but I have trouble getting the mock injection right for this case:
OurService that uses the DatetimeService and NumberFormatterService.
NumberFormatterService also uses the DatetimeService.
DatetimeService should be mocked.
I also posted this issue on StackOverflow, but after realizing, that this problem happens only sometimes and quite randomly, I could imagine that this is a bug, so I decided to open an issue here. In fact, it could be a timing issue. (Or caching?)
An example of the bug
describe('OurService',()=>{MockInstance.scope();letservice: OurService;beforeEach(async()=>{MockInstance(DatetimeService,'locale',()=>'en-US');awaitMockBuilder(OurService).mock(DatetimeService).provide(NumberFormatterService);service=TestBed.inject(OurService);});it('should be created',()=>{expect(service).toBeTruthy();});test('test setup is correct',()=>{expect(TestBed.inject(DatetimeService).locale()).toEqual('en-US');// worksexpect(service.datetimeService.locale()).toEqual('en-US');// worksexpect(service.numberFormatter.datetimeService.locale()).toEqual('en-US');// <== this fails (sometimes): locale is undefined});// ...});
Expected vs actual behavior
I would expect that the mocked Instance on DatetimeService is also always injected into the NumberFormatter.
The text was updated successfully, but these errors were encountered:
Description of the bug
We started using the very nice ng-mocks for our test, but I have trouble getting the mock injection right for this case:
I also posted this issue on StackOverflow, but after realizing, that this problem happens only sometimes and quite randomly, I could imagine that this is a bug, so I decided to open an issue here. In fact, it could be a timing issue. (Or caching?)
An example of the bug
Expected vs actual behavior
I would expect that the mocked Instance on DatetimeService is also always injected into the NumberFormatter.
The text was updated successfully, but these errors were encountered: