public annotate()

in src/assertion.ts [156:184]


  public annotate() {
    const { expected, actual } = this;
    const [expectedStr, actualStr] = AssertionTimeline.printAll([expected, actual]);
    const error = ['', `Expected: ${expectedStr}`, `Actual:   ${actualStr}`, '', 'Expectations:'];

    for (const entry of expected.items) {
      const prefix = `${entry.key}@${entry.frame}:`;
      const content = Assertion.stringifyExpectation(entry.value.expectation);
      error.push(`  ${entry.value.matched ? figures.tick : figures.cross} ${prefix} ${content}`);
    }

    const extraneous = actual.items.filter(e => !e.value.didMatchExpected);
    if (extraneous.length) {
      error.push('', 'Unmatched/Extraneous Actions:');
      for (const entry of extraneous) {
        if (entry.value.error) {
          error.push(
            `  ${entry.key}@${entry.frame}: ${Assertion.stringifyError(entry.value.error)}`,
          );
        } else {
          error.push(
            `  ${entry.key}@${entry.frame}: ${Assertion.stringifyAction(entry.value.value)}`,
          );
        }
      }
    }

    return error.join('\r\n');
  }