茉莉花量角器打字稿在 IT 块中出现一次预期故障后继续执行



我正在使用带有打字稿的量角器-茉莉花框架 -

所以我在描述中有多个 IT 块,所以在每个 IT 块中都有很多方法或期望条件我正在验证-

所以目前当其中一个期望失败时,整个 it 块就会终止,所以即使一步失败,我也想继续执行。

以下是规格

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();
}

你能帮帮我吗,

我相信停止是预期的行为。

无论如何,您可以尝试:

jasmine --stop-on-failure=false

这是文档。

我出于同样的目的使用这样的库 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()));
}

最新更新