lib/normalize.js
function(results, run, options, done) {

    run.errmessages = concatErrMessages(run.errmessages, results.errmessages);
    _.forOwn(results.modules, function(pkg, pkgName) {

      var npkg = {
        name: pkgName,
        suites: [],
        tests: pkg.tests,
        failures: pkg.failures,
        errors: pkg.errors,
        isFailure: (pkg.failures !== 0 && pkg.errors !== 0)
      };

      _.forOwn(pkg.completed, function(suite, suiteName) {

        var nsuite = {
          name: suiteName,
          pkgName: npkg.name,
          passed: suite.passed,
          failures: suite.failed,
          errors: suite.errors,
          skipped: suite.skipped,
          time: suite.time,
          cases: []
        };

        // Little weird here but the report object
        // will not report an error, it will instead
        // have X failed and empty assertions array.
        if (nsuite.failures > 0 && suite.assertions.length === 0)
          nsuite.errors = nsuite.failures;

        nsuite.isFailure = nsuite.failures !== 0 || nsuite.errors !== 0;
        npkg.suites.push(nsuite);

        _.each(suite.assertions, function(assertion) {

          var assert = _.clone(assertion, true);
          assert.screenshots = assert.screenshots || [];
          assert.isFailure = assertion.failure;
          nsuite.cases.push(assert);

          if (options.relativeScreenshots) {
            assert.screenshots = assert.screenshots.map(function(sspath) {
              return getRelativePath(options.fullOutputFilename, sspath);
            });
          }

          if (assert.isFailure)
            nsuite.isFailure = true;

        });

        if (nsuite.isFailure)
          npkg.isFailure = true;

      });

      run.addPackage(npkg);

      if (npkg.isFailure)
        run.isFailure = npkg.isFailure;

    });

    done(null, run);

  }
function(results, run, options, done) {

    run.errmessages = concatErrMessages(run.errmessages, results.errmessages);
    _.forOwn(results.modules, function(pkg, pkgName) {

      var npkg = {
        name: pkgName,
        suites: [],
        tests: pkg.tests,
        failures: pkg.failures,
        errors: pkg.errors,
        isFailure: (pkg.failures !== 0 && pkg.errors !== 0)
      };

      _.forOwn(pkg.completed, function(suite, suiteName) {

        var nsuite = {
          name: suiteName,
          pkgName: npkg.name,
          passed: suite.passed,
          failures: suite.failed,
          errors: suite.errors,
          skipped: suite.skipped,
          time: suite.time,
          cases: []
        };

        // Little weird here but the report object
        // will not report an error, it will instead
        // have X failed and empty assertions array.
        if (nsuite.failures > 0 && suite.assertions.length === 0)
          nsuite.errors = nsuite.failures;

        nsuite.isFailure = nsuite.failures !== 0 || nsuite.errors !== 0;
        npkg.suites.push(nsuite);

        _.each(suite.assertions, function(assertion) {

          var assert = _.clone(assertion, true);
          assert.screenshots = assert.screenshots || [];
          assert.isFailure = assertion.failure;
          nsuite.cases.push(assert);

          if (options.relativeScreenshots) {
            assert.screenshots = assert.screenshots.map(function(sspath) {
              return getRelativePath(options.fullOutputFilename, sspath);
            });
          }

          if (assert.isFailure)
            nsuite.isFailure = true;

        });

        if (nsuite.isFailure)
          npkg.isFailure = true;

      });

      run.addPackage(npkg);

      if (npkg.isFailure)
        run.isFailure = npkg.isFailure;

    });

    done(null, run);

  }
function ( results , run , options , done ) { run . errmessages = concatErrMessages ( run . errmessages , results . errmessages ) ; _ . forOwn ( results . modules , function ( pkg , pkgName ) { var npkg = { name : pkgName , suites : [ ] , tests : pkg . tests , failures : pkg . failures , errors : pkg . errors , isFailure : ( pkg . failures !== 0 && pkg . errors !== 0 ) } ; _ . forOwn ( pkg . completed , function ( suite , suiteName ) { var nsuite = { name : suiteName , pkgName : npkg . name , passed : suite . passed , failures : suite . failed , errors : suite . errors , skipped : suite . skipped , time : suite . time , cases : [ ] } ; // Little weird here but the report object // will not report an error, it will instead // have X failed and empty assertions array. if ( nsuite . failures > 0 && suite . assertions . length === 0 ) nsuite . errors = nsuite . failures ; nsuite . isFailure = nsuite . failures !== 0 || nsuite . errors !== 0 ; npkg . suites . push ( nsuite ) ; _ . each ( suite . assertions , function ( assertion ) { var assert = _ . clone ( assertion , true ) ; assert . screenshots = assert . screenshots || [ ] ; assert . isFailure = assertion . failure ; nsuite . cases . push ( assert ) ; if ( options . relativeScreenshots ) { assert . screenshots = assert . screenshots . map ( function ( sspath ) { return getRelativePath ( options . fullOutputFilename , sspath ) ; } ) ; } if ( assert . isFailure ) nsuite . isFailure = true ; } ) ; if ( nsuite . isFailure ) npkg . isFailure = true ; } ) ; run . addPackage ( npkg ) ; if ( npkg . isFailure ) run . isFailure = npkg . isFailure ; } ) ; done ( null , run ) ; }
Converts an object given to us by nightwatch into models.
Converts an object given to us by nightwatch into models .