lib/reporters/cucumber_reporter.js
function (eventName, payload) {
    var result;

    switch (eventName) {
      case 'BeforeScenario':
      case 'Scenario':
      case 'AfterScenario':
        result = {
          scenario: new Cucumber.Ast.Scenario(
            payload.scenario.keyword,
            payload.scenario.name,
            payload.scenario.description,
            payload.scenario.uri,
            payload.scenario.line,
            payload.scenario.scenarioOutlineLine,
            payload.scenario.background
          )
        };
        for (index in payload.scenario.steps) {
          var step = payload.scenario.steps[index];
          result.scenario.addStep(step);
        }
        result.scenario.failed = payload.scenario.failed;
        break;

      case 'BeforeFeature':
      case 'Feature':
      case 'AfterFeature':
        result = new Cucumber.Ast.Feature(
          payload.feature.keyword,
          payload.feature.name,
          payload.feature.description,
          payload.feature.uri,
          payload.feature.line,
          payload.feature.background
        );
        break;

      case 'BeforeFeatures':
      case 'Features':
      case 'AfterFeatures':
        result = new Cucumber.Ast.Features();
        for (index in payload.features) {
          var feature = payload.features[index];
          result.addFeature(feature);
        }
        break;

      case 'BeforeStep':
      case 'Step':
      case 'AfterStep':
        result = {
          step: this.hydrateStep(payload.step)
        };
        break;

      case 'StepResult':
        var stepResult = extend({}, payload.stepResult);
        stepResult.step = this.hydrateStep(stepResult.step);
        result = {
          stepResult: this.hydrateStepResult(stepResult)
        };
        break;

      case 'Background':
        result = {
          background: new Cucumber.Ast.Background(
            payload.background.keyword,
            payload.background.name,
            payload.background.description,
            payload.background.uri,
            payload.background.line
          )
        };
        for (index in payload.background.steps) {
          var step = payload.background.steps[index];
          result.background.addStep(step);
        }
        break;

      default:
        throw new Error('Invalid payload ' + eventName);
        break;
    }

    return result;
  }
function (eventName, payload) {
    var result;

    switch (eventName) {
      case 'BeforeScenario':
      case 'Scenario':
      case 'AfterScenario':
        result = {
          scenario: new Cucumber.Ast.Scenario(
            payload.scenario.keyword,
            payload.scenario.name,
            payload.scenario.description,
            payload.scenario.uri,
            payload.scenario.line,
            payload.scenario.scenarioOutlineLine,
            payload.scenario.background
          )
        };
        for (index in payload.scenario.steps) {
          var step = payload.scenario.steps[index];
          result.scenario.addStep(step);
        }
        result.scenario.failed = payload.scenario.failed;
        break;

      case 'BeforeFeature':
      case 'Feature':
      case 'AfterFeature':
        result = new Cucumber.Ast.Feature(
          payload.feature.keyword,
          payload.feature.name,
          payload.feature.description,
          payload.feature.uri,
          payload.feature.line,
          payload.feature.background
        );
        break;

      case 'BeforeFeatures':
      case 'Features':
      case 'AfterFeatures':
        result = new Cucumber.Ast.Features();
        for (index in payload.features) {
          var feature = payload.features[index];
          result.addFeature(feature);
        }
        break;

      case 'BeforeStep':
      case 'Step':
      case 'AfterStep':
        result = {
          step: this.hydrateStep(payload.step)
        };
        break;

      case 'StepResult':
        var stepResult = extend({}, payload.stepResult);
        stepResult.step = this.hydrateStep(stepResult.step);
        result = {
          stepResult: this.hydrateStepResult(stepResult)
        };
        break;

      case 'Background':
        result = {
          background: new Cucumber.Ast.Background(
            payload.background.keyword,
            payload.background.name,
            payload.background.description,
            payload.background.uri,
            payload.background.line
          )
        };
        for (index in payload.background.steps) {
          var step = payload.background.steps[index];
          result.background.addStep(step);
        }
        break;

      default:
        throw new Error('Invalid payload ' + eventName);
        break;
    }

    return result;
  }
CucumberReporter.hydratePayload(eventName, payload)
- eventName (String)
- payload (Object)