function resolveAssertionOptionsAndLhrs(baseOptions, unfilteredLhrs) {
  const {preset = '', ...optionOverrides} = baseOptions;
  let optionsToUse = optionOverrides;
  const presetMatch = preset.match(/lighthouse:(.*)$/);
  if (presetMatch) {
    const presetData = require(`./presets/${presetMatch[1]}.js`);
    optionsToUse = _.merge(_.cloneDeep(presetData), optionsToUse);
  }

  const {assertions = {}, matchingUrlPattern: urlPattern, aggregationMethod} = optionsToUse;
  const lhrs = urlPattern
    ? unfilteredLhrs.filter(lhr => doesLHRMatchPattern(urlPattern, lhr))
    : unfilteredLhrs;

  // Double-check we've only got one URL to look at that should have been pre-grouped in `getAllAssertionResults`.
  const uniqueURLs = new Set(lhrs.map(lhr => lhr.finalUrl));
  if (uniqueURLs.size > 1) throw new Error('Can only assert one URL at a time!');

  const medianLhrs = computeRepresentativeRuns([
    lhrs.map(lhr => /** @type {[LH.Result, LH.Result]} */ ([lhr, lhr])),
  ]);

  const auditsToAssert = [...new Set(Object.keys(assertions).map(key => _.kebabCase(key)))].map(
    assertionKey => {
      const [auditId, ...rest] = assertionKey.split(/\.|:/g).filter(Boolean);
      const auditInstances = lhrs.map(lhr => lhr.audits[auditId]).filter(Boolean);
      const failedAudit = auditInstances.find(audit => audit.score !== 1);
      const audit = failedAudit || auditInstances[0] || {};
      const auditTitle = audit.title;
      const auditLinks = splitMarkdownLink(audit.description || '')
        .map(segment => (segment.isLink ? segment.linkHref : ''))
        .filter(Boolean);
      const auditDocumentationLinkMatches = auditLinks.filter(
        link => link.includes('web.dev') || link.includes('developers.google.com/web')
      );
      const auditDocumentationLink =
        auditDocumentationLinkMatches.find(link => link.includes('web.dev')) ||
        auditDocumentationLinkMatches[0] ||
        auditLinks[auditLinks.length - 1];
      if (!rest.length) return {assertionKey, auditId, auditTitle, auditDocumentationLink};
      return {assertionKey, auditId, auditTitle, auditDocumentationLink, auditProperty: rest};
    }
  );

  return {
    assertions,
    auditsToAssert,
    medianLhrs,
    aggregationMethod,
    lhrs: lhrs,
    url: (lhrs[0] && lhrs[0].finalUrl) || '',
  };
}
@param {LHCI.AssertCommand.BaseOptions} baseOptions
@param {LH.Result[]} unfilteredLhrs