The test freezes when it expects (result) .toBe (null) the test fails. (Angular 2, jasmine)

I have a test that checks if a DOM part item has been removed by ngIf. When I check the DOM, by using: fixture.debugElement.query(By.css(".button-area")), resultit is either null, or DOM element.

If result- null, then the next test works fine. But if the test resultcontains an element, it does not just fail, it freezes the browser.

The test is as follows:

var result = fixture.debugElement.query(By.css(".button-area"))
expect(result).toBe(null)

I also tried expect(result).toEqual(null)and .toBeFalsy()that have the same result.

What is the correct way to check if the DOM element is deleted correctly?

UPDATE 1/23/2017

I found out that this problem is specified for the item returned:

fixture.debugElement.query(By.css(".button-area"))

It could be a mistake. angular 2 . document.getElementByClassName("button-area"), , .

+4
1

Jasmine Angular, , :

var result = fixture.debugElement.query(By.css(".button-area"))
expect(result === null).toBeTruthy()

, .

+3

Source: https://habr.com/ru/post/1667565/


All Articles