Dev Helpers
← Back

Inspect assertion diagnostics

Inspect assertion diagnostics using Node.js.

Open this example in the interactive library

Source code

import assert from "node:assert/strict";
console.log(
  (() => {
    try {
      assert.equal(1, 2);
    } catch (error) {
      return [error.code, error.actual, error.expected];
    }
  })(),
);

Sample output

[ 'ERR_ASSERTION', 1, 2 ]