src/utils.js
function cleanSuite(suite, totalTestsRegistered, config) {
  let duration = 0;
  const passingTests = [];
  const failingTests = [];
  const pendingTests = [];
  const skippedTests = [];

  const beforeHooks = _.map(
    [].concat(suite._beforeAll, suite._beforeEach),
    test => cleanTest(test, config)
  );

  const afterHooks = _.map(
    [].concat(suite._afterAll, suite._afterEach),
    test => cleanTest(test, config)
  );

  const tests = _.map(
    suite.tests,
    test => {
      const cleanedTest = cleanTest(test, config);
      duration += test.duration || 0;
      if (cleanedTest.state === 'passed') passingTests.push(cleanedTest.uuid);
      if (cleanedTest.state === 'failed') failingTests.push(cleanedTest.uuid);
      if (cleanedTest.pending) pendingTests.push(cleanedTest.uuid);
      if (cleanedTest.skipped) skippedTests.push(cleanedTest.uuid);
      return cleanedTest;
    }
  );

  totalTestsRegistered.total += tests.length;

  const cleaned = {
    uuid: uuid.v4(),
    title: stripAnsi(suite.title),
    fullFile: suite.file || '',
    file: suite.file ? suite.file.replace(process.cwd(), '') : '',
    beforeHooks,
    afterHooks,
    tests,
    suites: suite.suites,
    passes: passingTests,
    failures: failingTests,
    pending: pendingTests,
    skipped: skippedTests,
    duration,
    root: suite.root,
    rootEmpty: suite.root && tests.length === 0,
    _timeout: suite._timeout
  };

  const isEmptySuite = _.isEmpty(cleaned.suites)
    && _.isEmpty(cleaned.tests)
    && _.isEmpty(cleaned.beforeHooks)
    && _.isEmpty(cleaned.afterHooks);

  return !isEmptySuite && cleaned;
}
function cleanSuite(suite, totalTestsRegistered, config) {
  let duration = 0;
  const passingTests = [];
  const failingTests = [];
  const pendingTests = [];
  const skippedTests = [];

  const beforeHooks = _.map(
    [].concat(suite._beforeAll, suite._beforeEach),
    test => cleanTest(test, config)
  );

  const afterHooks = _.map(
    [].concat(suite._afterAll, suite._afterEach),
    test => cleanTest(test, config)
  );

  const tests = _.map(
    suite.tests,
    test => {
      const cleanedTest = cleanTest(test, config);
      duration += test.duration || 0;
      if (cleanedTest.state === 'passed') passingTests.push(cleanedTest.uuid);
      if (cleanedTest.state === 'failed') failingTests.push(cleanedTest.uuid);
      if (cleanedTest.pending) pendingTests.push(cleanedTest.uuid);
      if (cleanedTest.skipped) skippedTests.push(cleanedTest.uuid);
      return cleanedTest;
    }
  );

  totalTestsRegistered.total += tests.length;

  const cleaned = {
    uuid: uuid.v4(),
    title: stripAnsi(suite.title),
    fullFile: suite.file || '',
    file: suite.file ? suite.file.replace(process.cwd(), '') : '',
    beforeHooks,
    afterHooks,
    tests,
    suites: suite.suites,
    passes: passingTests,
    failures: failingTests,
    pending: pendingTests,
    skipped: skippedTests,
    duration,
    root: suite.root,
    rootEmpty: suite.root && tests.length === 0,
    _timeout: suite._timeout
  };

  const isEmptySuite = _.isEmpty(cleaned.suites)
    && _.isEmpty(cleaned.tests)
    && _.isEmpty(cleaned.beforeHooks)
    && _.isEmpty(cleaned.afterHooks);

  return !isEmptySuite && cleaned;
}
function cleanSuite ( suite , totalTestsRegistered , config ) { let duration = 0 ; const passingTests = [ ] ; const failingTests = [ ] ; const pendingTests = [ ] ; const skippedTests = [ ] ; const beforeHooks = _ . map ( [ ] . concat ( suite . _beforeAll , suite . _beforeEach ) , test => cleanTest ( test , config ) ) ; const afterHooks = _ . map ( [ ] . concat ( suite . _afterAll , suite . _afterEach ) , test => cleanTest ( test , config ) ) ; const tests = _ . map ( suite . tests , test => { const cleanedTest = cleanTest ( test , config ) ; duration += test . duration || 0 ; if ( cleanedTest . state === 'passed' ) passingTests . push ( cleanedTest . uuid ) ; if ( cleanedTest . state === 'failed' ) failingTests . push ( cleanedTest . uuid ) ; if ( cleanedTest . pending ) pendingTests . push ( cleanedTest . uuid ) ; if ( cleanedTest . skipped ) skippedTests . push ( cleanedTest . uuid ) ; return cleanedTest ; } ) ; totalTestsRegistered . total += tests . length ; const cleaned = { uuid : uuid . v4 ( ) , title : stripAnsi ( suite . title ) , fullFile : suite . file || '' , file : suite . file ? suite . file . replace ( process . cwd ( ) , '' ) : '' , beforeHooks , afterHooks , tests , suites : suite . suites , passes : passingTests , failures : failingTests , pending : pendingTests , skipped : skippedTests , duration , root : suite . root , rootEmpty : suite . root && tests . length === 0 , _timeout : suite . _timeout } ; const isEmptySuite = _ . isEmpty ( cleaned . suites ) && _ . isEmpty ( cleaned . tests ) && _ . isEmpty ( cleaned . beforeHooks ) && _ . isEmpty ( cleaned . afterHooks ) ; return ! isEmptySuite && cleaned ; }
Return a plain-object representation of `suite` with additional properties for rendering.

@param {Object} suite
@param {Object} totalTestsRegistered
@param {Integer} totalTestsRegistered.total

@return {Object|boolean} cleaned suite or false if suite is empty
Return a plain - object representation of suite with additional properties for rendering .