protractor-jasmine2-html-reporter doesn't consolidate results for all test when tests are shared using 'shardTestFiles': true in conf file

后端 未结 5 1553
鱼传尺愫
鱼传尺愫 2021-01-14 20:04

Recently we have configured our e2e-tests to be on Jenkins & soon we realized that we have to use shared test files: true options as complete suite run is taking very lo

5条回答
  •  悲哀的现实
    2021-01-14 20:36

    Solution from Aditya works fine for me. My example config file: var Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter');

    exports.config = { framework: 'jasmine2', seleniumAddress: 'http://localhost:4444/wd/hub', /multiCapabilities: [ { 'browserName': 'chrome', 'shardTestFiles': true, 'maxInstances': 2, chromeOptions: { args: ['chrome.switches', '--disable-extensions'] } }, { 'browserName': 'firefox' } ],/ capabilities: { 'browserName': 'chrome', 'shardTestFiles': true, 'maxInstances': 2, chromeOptions: { args: ['chrome.switches', '--disable-extensions'] } }, suites: { loginpage: 'login.js', addproduct: 'addproduct.js' }, //specs: ['addproduct.js'], jasmineNodeOpts: { onComplete: null, isVerbose: false, includeStackTrace: true, showColors: true, defaultTimeoutInterval: 30000 },

    onPrepare: function() {
        return new Promise(function(fulfill, reject) {
            browser.getCapabilities().then(function(value) {
                reportName = value.get(Math.random(8,2)) + '_' + value.get('browserName') + '_' + Math.floor(Math.random() * 1E16);
                jasmine.getEnv().addReporter(
                    new Jasmine2HtmlReporter({
                        //cleanDestination: false,
                        savePath: 'target/',
                        //docTitle: 'Web UI Test Report',
                        screenshotsFolder: 'image',
                        //takeScreenshots: true,
                        //takeScreenshotsOnlyOnFailures: true,
                        consolidate: true,
                        consolidateAll: true,
                       // preserveDirectory: true,
                        //fixedScreenshotName: true,
                        filePrefix: reportName + ".html"
                    })
                );
                fulfill();
            });
        });
    },
    afterLaunch: function afterLaunch() {
        var fs = require('fs');
        var output = '';
        fs.readdirSync('target/').forEach(function(file) {
            if (!(fs.lstatSync('target/' + file).isDirectory()))
                output = output + fs.readFileSync('target/' + file);
        });
        fs.writeFileSync('target/ConsolidatedReport.html', output, 'utf8');
    }
    

    }

提交回复
热议问题