I am writing a Angular Unit Testing which I am facing with an error. If I write toBeFalsy() the test will fail. But If I write not.toBe(true) the test will work.
May someone help me.
let fixture: ComponentFixture<RootComponent>;
let debugElement: DebugElement;
beforeEach(async () => {
fixture = TestBed.createComponent(RootComponent);
await executeChangeDetection(fixture);
component = fixture.componentInstance;
debugElement = fixture.debugElement.query(By.css('#overlay'));
});
it('should hide overlay and reset timeout', () => {
const appState = new ApplicationStateService(null as any);
appState.timeout = false;
component.isTimeoutOverlayVisible = appState.timeout;
fixture.detectChanges();
expect(debugElement.nativeElement).toBeFalsy();
});
toBeFalsy() the test will fail but as message will come that.
Expected <overlay id="overlay">...</overlay> to be falsy.
not.toBe(true) the test will work.