报告'protractor-jasmine2-screenshot-reporter'和'jasmine-reporter'在一个配置文件中,但Jasmine2-Screenshot记者无法正常工作

时间:2016-02-24 14:39:09

标签: node.js protractor

以下是配置文件,其中包含'protractor-jasmine2-screenshot-reporter'和'jasmine-reporter'

它单独工作正常但如果我结合了量角器-jasmine2-screenshot-reporter'不起作用,是因为我有两个'onPrepare'功能

 var HtmlScreenshotReporter = require('C:/Protractor_Scripts/node_modules/protractor-jasmine2-screenshot-reporter');

        var reporter = new HtmlScreenshotReporter({
          dest: 'C:/Protractor_Scripts/Screenshots',
          filename: 'Report.html'
        });

        exports.config = {

        directConnect: false,

        multiCapabilities: [


            {'browserName': 'chrome'},
            {'browserName': 'firefox'}

        ],

        allScriptsTimeout: 1200000,

        framework: 'jasmine2',

        specs: ['C:/Protractor_Scripts/Protractor/Driver/Driver.js'],

           // Setup the report before any tests start
           beforeLaunch: function() {
              return new Promise(function(resolve){
                reporter.beforeLaunch(resolve);
              });
           },


        onPrepare: function() {
              jasmine.getEnv().addReporter(reporter);
           },

           // Close the report after all tests finish
           afterLaunch: function(exitCode) {
              return new Promise(function(resolve){
                reporter.afterLaunch(resolve.bind(this, exitCode));
              });
           },


    Jasmine Reporter which is used to generate xml reports  
        onPrepare: function() {

            var jasmineReporters = require('C:/Protractor_Scripts/node_modules/jasmine-reporters');
            jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
                consolidateAll: true,
                savePath: 'C:/Protractor_Scripts/Results',
                filePrefix: 'xmloutput'
            }));
        },

         // ----- Options to be passed to minijasminenode -----
          jasmineNodeOpts: {
            // onComplete will be called just before the driver quits.
            onComplete: null,
            // If true, display spec names.
            isVerbose: false,
            // If true, print colors to the terminal.
            showColors: true,
            // If true, include stack traces in failures.
            includeStackTrace: true,
            // Default time to wait in ms before a test fails.
            defaultTimeoutInterval: 1200000
          }

        };

1 个答案:

答案 0 :(得分:0)

不要定义两个onPrepare函数,将所有内容放在一个函数中:

onPrepare: function() {
    jasmine.getEnv().addReporter(reporter);

    var jasmineReporters = require('C:/Protractor_Scripts/node_modules/jasmine-reporters');
    jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
        consolidateAll: true,
        savePath: 'C:/Protractor_Scripts/Results',
        filePrefix: 'xmloutput'
    }));
},