NickTomlin / protractor-flake

Rerun potentially flakey protractor tests before failing.
MIT License
80 stars 51 forks source link

Protractor Flake is not working with cucumber? #113

Open abubakarafzal opened 4 years ago

abubakarafzal commented 4 years ago

Hi there!

Thanks for submitting an issue! Please provide the following information:

'use strict';

const protractorFlake = require('protractor-flake');
const argv = require('yargs').argv;

protractorFlake({
    maxAttempts: 2,
    parser: 'cucumber',
    protractorArgs: [
        '../QuinCCucumber/config.js',

    ]
}, (status) => {
    process.exit(status);
});`

**config.ts**

`import * as path from "path";
import { browser, Config } from "protractor";
import { Reporter } from "./Test/hooks/reporter";
//import { Reporter } from "../hooks/reporter";

const jsonReports = process.cwd() + "/reports/json";
const retry = require('protractor-retry').retry;
const protractorFlake = require('protractor-flake');
const argv = require('yargs').argv;
export const config: Config = {
    defaultTimeoutInterval: 1445500000,
    seleniumAddress: "http://127.0.0.1:4444/wd/hub",

    SELENIUM_PROMISE_MANAGER: false,

    baseUrl: "http://lakshmi:4443/LoginPage.html",
    suites:{
        "Login": "./Test/features/login.feature",
        "case": "./Test/features/case.feature",

    },

    capabilities: {
        browserName: 'chrome',
        unexpectedAlertBehaviour: 'accept',
        'goog:chromeOptions': {
            'w3c': false,

        }
    },
    framework: 'custom',
    frameworkPath: require.resolve('protractor-cucumber-framework'),
    ignoreUncaughtExceptions: true,

    specs: [

        "./Test/features/login.feature",

        "./Test/features/case.feature",
    ],

    onPrepare: () => {
        browser.ignoreSynchronization = true;
        browser.manage().window().maximize();
        browser.manage().timeouts().setScriptTimeout(6000000);
        Reporter.createDirectory(jsonReports);
        retry.onPrepare();

    },
    protractorFlake:[{
        maxAttempts: 2,
        parser: 'cucumber',

    }, (status) => {
        process.exit(status);
    }],

    cucumberOpts: {

        // required step definitions
        compiler: [],
        require: ['../reporting/cucumber-screenshot.js','../steps/*.js',
            path.resolve(process.cwd(), './/Test/steps/*.js'),
            path.resolve(process.cwd(), './/Test/hooks/afterHooks.js'),

        ],
        // require : [ '../steps/*.js',
        // path.resolve(process.cwd(), './/Test/steps/*.js'),
        //  ],
        removeOriginalJsonReportFile : true,
        format: "json:./reports/json/cucumber_report.json",
        strict  : true,
        dryRun  : false,
        tags    : []
    },

onComplete: () => {
        Reporter.createHTMLReport();
    },

    plugins: [{
        package: require.resolve('protractor-multiple-cucumber-html-reporter-plugin'),
        options:{
            automaticallyGenerateReport: true,
            removeExistingJsonReportFile: true,
            openReportInBrowser: true,
            pageTitle : 'QUIN-C',
            reportName :'QUIN-C Test Report',

            //jsonOutputPath: './features',     //?featuresJsonPath
            removeOriginalJsonReportFile: true, //! This Option will Delete Generated Json File
            pageFooter: '<div class="container"><div class="row"><div class="col-sm-4"></div><img src="https://res-4.cloudinary.com/crunchbase-production/image/upload/c_lpad,h_256,w_256,f_auto,q_auto:eco/v1397183701/77e5f4c19af7b22148f5e1016925b98e.jpg" class="img-fluid"alt="no image"></div>',
            displayDuration: true,
        }
    }],

    getPageTimeout: 30000,
};

`

Tests failed but no specs were found. All specs will be run again.**

All of my Pass and failed test case run after one Scenerio fail. kindly tell me what to do i just want to run the failed test after execution.

You can collect the first few items easily with the trouble cli npx @nicktomlin/trouble protractor protractor-flake (or npm i -g @nicktomlin/trouble && trouble protractor protractor-flake)

achuinard commented 4 years ago

You shouldn't need this plugin anymore, you can just include a retry integer argument under the cucumberOpts in your protractor.conf.

abhinaba-ghosh commented 4 years ago

@achuinard Can you share your piece of code, please?