jha*_*amm 4 javascript jasmine
我已经开始为我的js文件编写测试,而且我得到了一个undefined我没想到的地方.这是我的代码:
describe('show jasmine testing', function() {
var x;
beforeEach(function() {
x = 3;
});
describe('booleans', function() {
it('should return true', function() {
expect(true).toBe(true);
});
});
describe('ints', function() {
console.log('This is x: ' + x);
expect(x).toBe(3);
});
});
Run Code Online (Sandbox Code Playgroud)
在我的ints测试中,我的x变量是undefined,所以测试总是失败.根据我的理解应该是3因为beforeEach块在每个describe块之前运行.我错过了什么?
| 归档时间: |
|
| 查看次数: |
1981 次 |
| 最近记录: |