JasmineJS教程

JasmineJS afterEach()

与 beforeEach() 一样,afterEach() 的工作方式完全相同。它在执行规范块之后执行。让我们使用以下代码修改前面的示例。
var currentVal = 0; 
afterEach(function() { 
   currentVal = 5;  
});  
describe("Different Methods of Expect Block",function() { 
   it("first call ", function() { 
      expect(currentVal).toEqual(0);     
   });     
   
   it("second call ",  function() { 
      expect(currentVal).toEqual(5);     
   });
});
在上面的例子中,当运行第一个规范块时, currentVal 的值为 0。因此,它将通过测试用例,但在运行第一个 it 块后,Jasmine compile 运行了 afterEach () 块,它使 currentVal 的值为 5、因此它也满足第二种情况并产生一个绿色屏幕截图作为输出。
AfterEach
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4