【问题标题】:jasmine protractor typescript to continue execution after one expected failure in it block茉莉量角器打字稿在一个预期的失败后继续执行它块
【发布时间】:2018-11-11 10:14:34
【问题描述】:

我正在使用 protractor-jasmine 框架和 typescript -

所以我在 describe 中有多个 it 块,所以在每个 it 块中都有许多方法或期望条件我正在验证 -

所以目前当其中一个期望失败然后整个它块被终止,所以我想在一步失败后继续执行。

以下是Spec.ts

it('Should display Introduction screen with title correctly', () => {

    page.navigateTo('/');

    console.log('Verifying  Title is displayed...');
    expect(page.getTitle()).toBe('Quick Refund Estimator');

    console.log('Verifying button -Estimate my taxes is displayed..');
    expect(page.getButtonText_EstimatesMyTaxes()).toEqual(true);

});

Po.ts如下 -

export class IntroductionPage {

navigateTo(url: string): void {
    browser.get(url);
    browser.waitForAngular();
}

getTitle() {
    return element(by.className('qreTitl')).getText();
}

getButtonText_EstimatesMyTaxes() {   
    return element(by.buttonText('Estimate my taxe')).isDisplayed();
}

在当前情况下,当以下方法失败时,将停止进一步执行,但我想继续所有步骤执行

getTitle() {
   return element(by.className('qreTitl')).getText();
}

你能帮帮我吗,

【问题讨论】:

标签: typescript protractor jasmine2.0


【解决方案1】:

我认为停止的事实是预期的行为。

不管怎样,你可以试试:

jasmine --stop-on-failure=false

这里是documentation

【讨论】:

  • 我应该在哪里添加这个 -jasmine --stop-on-failure=false。我正在使用 protractor.conf.js 而我没有使用 spec/support/jasmine.json
  • @simond, --stop-on-failure 仅在您从 cmd 行通过 jasmine cli 运行 jasmine 脚本时才有效。对于量角器,无法使用此选项。
【解决方案2】:

我出于同样的目的使用此类库 https://www.npmjs.com/package/protractor-stop-describe-on-failure . 描述块将在第一次失败后停止执行它以最小化测试运行时间。

你应该安装这个库 npm install protractor-stop-describe-on-failure --save-dev 然后在你的量角器配置文件中,在 jasmine 中注册记者:

const DescribeFailureReporter = require('protractor-stop-describe-on-failure');

exports.config = {
   onPrepare: function() {
      jasmine.getEnv().addReporter(DescribeFailureReporter(jasmine.getEnv()));
   }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-12-06
    • 2014-06-01
    • 1970-01-01
    • 2016-11-27
    • 2016-09-16
    • 2017-06-11
    • 1970-01-01
    相关资源
    最近更新 更多