茉莉是应该按照声明的顺序或以随机顺序执行规范吗? [英] Is jasmine supposed to execute specs in the order they are declared or in a random order?
本文介绍了茉莉是应该按照声明的顺序或以随机顺序执行规范吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
取消评论最后一个规格。所有地狱都松了......为什么?
un-comment the last spec. All hell breaks loose... why?
describe('test', function() {
var index = 1;
it('test 1', function() {
expect(index).toBe(1);
index++;
});
it('test 2', function() {
expect(index).toBe(2);
index++;
});
it('test 3', function() {
expect(index).toBe(3);
index++;
});
it('test 4', function() {
expect(index).toBe(4);
index++;
});
it('test 5', function() {
expect(index).toBe(5);
index++;
});
it('test 6', function() {
expect(index).toBe(6);
index++;
});
it('test 7', function() {
expect(index).toBe(7);
index++;
});
it('test 8', function() {
expect(index).toBe(8);
index++;
});
it('test 9', function() {
expect(index).toBe(9);
index++;
});
it('test 10', function() {
expect(index).toBe(10);
index++;
});
// it('test 11', function() {
// expect(index).toBe(11);
// index++;
// });
});
感谢@PWKad指出当有超过10次测试时会发生这种情况。
thanks to @PWKad for pointing out this happens when there are more than 10 tests.
推荐答案
是的,Jasmine按顺序执行规范(it)。从2.3.0到2.3.3存在超过10个规格的问题。我在2.3.3中遇到了同样的问题,问题在2.3.4中修复。
Yes, Jasmine executes the specs (it) in order. There was an issue from 2.3.0 to 2.3.3 with more than 10 specs. I hit the same issue in 2.3.3, the issue is fixed in 2.3.4.
https://github.com/jasmine/jasmine/issues/850
我刚用2.3.4代替2.3 .3我的15项测试终于通过了。
I just used 2.3.4 in place of 2.3.3 and my 15 tests finally passed.
这篇关于茉莉是应该按照声明的顺序或以随机顺序执行规范吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文