Skip to content

Use GitHub markdown diff syntax highlighting for assertion failures #254

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,
-           id: 555,
          }
        ],
        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,
-           id: 555,
          }
        ],
        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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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