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 按顺序执行规范(它).从 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.
这篇关于茉莉花应该按照声明的顺序还是随机顺序执行规范?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:茉莉花应该按照声明的顺序还是随机顺序执行规
				
        
 
            
        - 如何显示带有换行符的文本标签? 2022-01-01
 - 从原点悬停时触发 translateY() 2022-01-01
 - 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01
 - 为什么我的页面无法在 Github 上加载? 2022-01-01
 - 在不使用循环的情况下查找数字数组中的一项 2022-01-01
 - 为什么悬停在委托事件处理程序中不起作用? 2022-01-01
 - 使用 iframe URL 的 jQuery UI 对话框 2022-01-01
 - 如何调试 CSS/Javascript 悬停问题 2022-01-01
 - 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01
 - 如何向 ipc 渲染器发送添加回调 2022-01-01
 
						
						
						
						
						
				
				
				
				