Skip to content

Use GitHub markdown diff syntax highlighting for assertion failures #254

@c24w

Description

@c24w

It would be nice if assertion failures used syntax highlighting, to make them easier to read, especially when the output is long (e.g. assert.deepEqual).

The following markdown achieves this without changing the layout:

Failed Tests
❌ Test name
... Skipped lines
  {
    thing: {
+     id: 111,
-     id: 222,
      prop1: 'aaa',
      prop2: 'bbb'
    },
    prop3: 'ccc',
    prop4: 'ddd',
...
          {
+           id: 333,
+           rrp: 444
-           id: 555,
-           rrp: 666
          }
        ],
        prop5: 'eee',
        prop6: 'fff',
        prop7: [
<table>
  <thead>
    <tr>
      <th>Failed Tests</th>
    </tr>
  </thead>
  <tbody>
      <tr>
        <td>
<details>
<summary>❌ Test name</summary>

```diff
... Skipped lines
  {
    thing: {
+     id: 111,
-     id: 222,
      prop1: 'aaa',
      prop2: 'bbb'
    },
    prop3: 'ccc',
    prop4: 'ddd',
...
          {
+           id: 333,
+           rrp: 444
-           id: 555,
-           rrp: 666
          }
        ],
        prop5: 'eee',
        prop6: 'fff',
        prop7: [
```
</details>
        </td>
      </tr>
  </tbody>
</table>

It's a bit clumsy, because of the HTML table, but seems to render okay on GitHub. Can you see any drawbacks?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions