量角器继续尽管之前每个函数错误而没有调用完成

时间:2017-04-17 17:06:10

标签: javascript angular protractor

在我的量角器测试中,我有几个beforeEach函数。如果其中一个包含错误(实际上在我的所有测试运行后都打印出来),量角器就会继续进入下一个beforeEach,这会浪费大量时间,因为它必须执行可能正确的代码才能最终退出并通知我几乎立即发生的错误。一个例子:

beforeEach(function(done) {
  // I forget to actually call the function thus testDocument is a function not a document
  this.testDocument = someMongoDocumentConsutrctor;
  // This throws an error since testDocument is mistakenly not a document and has no save
  // This is where the protractor tests should exit immediately
  // And since .save is undefined there is no way this code calls done
  this.testDocument.save(done);
});

it('should show show the welcome overlay', function() {
  // This code actually throws an error while the test is running
  // before protractor logs anything else including the error that must've already occurred
  expect(overlay.welcomeMessage.isDisplayed()).toBe(true);
})

测试执行期间抛出的错误消息是:

(node:34486) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): NoSuchElementError: No element found using locator: By(css selector, tutorial-overlay)

量角器总输出的开头是(描述块名称已编辑):

Spec started
(node:34486) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): NoSuchElementError: No element found using locator: By(css selector, tutorial-overlay)
A Jasmine spec timed out. Resetting the WebDriver Control Flow.

  Outer describe block name

    Inner describe block name
      ✗ should show show the welcome overlay
        - Failed: this.testDocument.save is not a function

0 个答案:

没有答案