3

我希望能获得一些关于为什么我会出现间歇性测试失败的线索。我有一个验收测试在我运行整个模块时失败,但所有单独的测试在单独运行时都通过了。这个问题似乎与使用围绕断言的循环有关,因为我有两个不同的测试失败,并且都有一个类似这样的 forEach 循环:

import Ember from 'ember';
import { module, test } from 'qunit';
import startApp from "dwellconnect-app/tests/helpers/start-app";

var things;

module('Acceptance | something', {
  beforeEach: function() {
    this.application = startApp();
    things = [
      Ember.Object({someProperty: '1'}),
      Ember.Object({someProperty: '2'}),
      Ember.Object({someProperty: '3'}),
      Ember.Object({someProperty: '4'}),
    ]

  },

  afterEach: function() {
    Ember.run(this.application, 'destroy');
  }
});

test('Something', function(assert) {
  assert.expect(4);

  visit('/something');

  andThen(function() {
    // Check that each thing is on the page
    things.forEach(function(thing) {
      var someSelector = 'span:contains("' + thing.someProperty + '")';
      assert.equal(find(someSelector).length, 1, 'Shows each thing');
    });
  });
});

首先,这种方法有什么问题吗?如果有,围绕数据数组构建一组断言的正确方法是什么。如果不是,还有什么可能导致问题?即使您只能提供间歇性故障的可能方案,它也可能引导我走向正确的方向。现在没有错误,这让我发疯。我不确定夏洛克·福尔摩斯能不能找到这个。

4

0 回答 0