code: function createDone({ meta, emit, test: t, options, same }) {
    return function ondone(result) {
      let test = null;
  
      /* istanbul ignore if */
      if (same) {
        test = testsCache[t.title];
      } else {
        test = Object.assign({}, t, result, { isPending: false });
      }
  
      const { reason, ...testObject } = test;
  
      /* istanbul ignore if */
      if (options.snapshots) {
        testsCache[test.title] = testObject;
        testsCache[test.title].run = false;
      }
  
      if (test.isRejected) {
        meta.stats.fail += 1;
  
        test.reason.stack = cleanup(test.reason.stack);
        emit('fail', meta, test);
  
        /* istanbul ignore if */
        if (options.snapshots) {
          testsCache[test.title].reason = { stack: reason && reason.stack };
        }
      }
      if (test.isFulfilled) {
        if (test.skip) {
          emit('skip', meta, test);
        } else if (test.todo) {
          emit('todo', meta, test);
        } else {
          meta.stats.pass += 1;
          emit('pass', meta, test);
        }
      }
  
      emit('afterEach', meta, test);
      return test;
    };
  }
docs: /* eslint-disable max-statements