Print message on expect() assert failure

后端 未结 8 2196
一个人的身影
一个人的身影 2020-12-15 02:11

Is there a way to print a custom error message when a Jasmine expect() fails?

As an example, for end to end testing I have an array of web pages and I u

8条回答
  •  遥遥无期
    2020-12-15 02:54

    Yes, we can print a custom error message when an expect() failed in Jasmine.

     Code Snippet:
    
      it('print a custom error message when an expect failed', function() {
    
        var elemenToBeDisplayed=element(by.css("userName"));
    
        /*custom error message will be displayed if expected condition 
        failed*/
    
        expect(elemenToBeDisplayed.isPresent).toBe(true,'Write your custom       
             error message here');
       });
    

提交回复
热议问题