问题
I am using protractor-jasmine framework with typescript -
so i have multiple it blocks within describe , so within each it block there are many methods or expect conditions i am verifying-
so currently when one of the expect failed then whole it block is terminated , so i want to continue the execution even after one step fail.
Below is 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 as below -
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();
}
In current scenario when below methods fail then further execution is stopped but i want to continue all step execution
getTitle() {
return element(by.className('qreTitl')).getText();
}
Could you please help me,
回答1:
The fact that stops I believe is the intended behavior.
Anyway, you could maybe try with:
jasmine --stop-on-failure=false
here is the documentation.
回答2:
I use for the same purpose such library https://www.npmjs.com/package/protractor-stop-describe-on-failure . Describe block will stop executing it blocks after first fail to minimize test runtime.
You should install this library
npm install protractor-stop-describe-on-failure --save-dev
and then in your protractor configuration file, register the reporter in jasmine:
const DescribeFailureReporter = require('protractor-stop-describe-on-failure');
exports.config = {
onPrepare: function() {
jasmine.getEnv().addReporter(DescribeFailureReporter(jasmine.getEnv()));
}
来源:https://stackoverflow.com/questions/50640562/jasmine-protractor-typescript-to-continue-execution-after-one-expected-failure-i