- JasmineJS 教程
- JasmineJS - 主页
- JasmineJS - 概述
- JasmineJS - 环境设置
- JasmineJS - 编写文本和执行
- JasmineJS - BDD 架构
- JasmineJS - 测试构建块
- JasmineJS - 匹配器
- JasmineJS - 跳过块
- JasmineJS - 平等检查
- JasmineJS - 布尔检查
- JasmineJS - 顺序检查
- JasmineJS - 空检查
- JasmineJS - 不平等检查
- JasmineJS - 不是数字检查
- JasmineJS - 异常检查
- JasmineJS - beforeEach()
- JasmineJS - afterEach()
- JasmineJS - 间谍
- JasmineJS 有用资源
- JasmineJS - 快速指南
- JasmineJS - 有用的资源
- JasmineJS - 讨论
JasmineJS - afterEach()
与 beforeEach() 一样,afterEach() 的工作方式完全相同。它在执行spec块之后执行。让我们使用以下代码修改前面的示例。
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);
});
});
在上面的例子中,在运行第一个spec块时,currentVal的值为0。因此,它将通过测试用例,但在运行第一个it块之后,Jasmine编译运行了afterEach()块,这使得currentVal 为 5。因此它也满足第二种情况并产生绿色屏幕截图作为输出。
