Change8

assert@0.3.0

Breaking Changes
📦 remixView on GitHub →
2 breaking5 features🐛 2 fixes🔧 7 symbols

Summary

The `@remix-run/assert` module has been updated to align more closely with Node's `node:assert/strict`, introducing changes to error structures and improving deep equality checks.

⚠️ Breaking Changes

  • Assertion failures now expose Node-style `code` and `generatedMessage` fields, which may break consumers relying on the previous error structure.
  • Core assertion APIs now throw custom `Error` message objects directly instead of potentially throwing strings or other types, which may break consumers expecting specific error types.

Migration Steps

  1. Review code that inspects error objects thrown by assertions to account for the new `code` and `generatedMessage` fields.
  2. Review code that catches assertion errors to expect custom `Error` message objects instead of potentially other types.

✨ New Features

  • The default export of `@remix-run/assert` is now callable as an alias for `assert.ok`, matching Node's `assert(value)` usage.
  • Assertion failures now expose Node-style `code` and `generatedMessage` fields.
  • Strict equality now uses `Object.is`, meaning `NaN` equals `NaN` and `0` does not equal `-0`.
  • Deep equality now compares built-in objects such as `Date`, `RegExp`, `Error`, `Map`, `Set`, typed arrays, symbol properties, prototypes, and cyclic structures.
  • Added `assert.partialDeepEqual(actual, expected)`, a strict-by-default counterpart to Node's `assert.partialDeepStrictEqual`.

🐛 Bug Fixes

  • Fixed behavior of `throws`/`rejects`/`doesNotThrow`/`doesNotReject` to follow Node's expected-error and message argument behavior more closely.
  • Tightened Node compatibility for assertion behavior, including generated-message metadata, expected-error argument validation, `Error` constructor and instance matching, partial array and byte-sequence matching, `URLSearchParams` comparisons, and invalid-argument handling for `match`/`doesNotMatch`.

Affected Symbols