Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8ecdf42
lib: restructure assert to use clasd implementation for basics assert
miguelmarcondesf Apr 25, 2025
3539371
lib: change static methods and add other compare methods
miguelmarcondesf May 4, 2025
3d1c2f9
lib: update assert module to use instance methods and preserve origin…
miguelmarcondesf May 5, 2025
6921bce
test: add Assert class tests with additional error scenarios
miguelmarcondesf May 7, 2025
226748c
test: update snapshot fixtures
miguelmarcondesf May 8, 2025
435dc0b
lib: update Assert class to use instance methods for error handling
miguelmarcondesf May 8, 2025
5c35132
lib: add doesNotThrow and doesNotReject methods in Assert class
miguelmarcondesf May 8, 2025
eecf3cc
lib: add ifError method to Assert class
miguelmarcondesf May 9, 2025
4eb5923
lib: refactor expectedException function into a private method in Ass…
miguelmarcondesf May 9, 2025
e1f06e4
lib: refactor compareExceptionKey function into a private method in A…
miguelmarcondesf May 9, 2025
8e6a8c2
lib: add private #waitForActual method to Assert class for promise ha…
miguelmarcondesf May 9, 2025
787c152
lib: add innerFail as private method to Assert class
miguelmarcondesf May 9, 2025
9e72716
lib: add getActual as priivate method to Assert class
miguelmarcondesf May 9, 2025
a4f291b
lib: move checkIsPromise function to private method in Assert class
miguelmarcondesf May 9, 2025
863075e
lib: move hasMatchingError as private method to Assert
miguelmarcondesf May 9, 2025
27269f9
test: move Assert class instance tests to separate file
miguelmarcondesf May 9, 2025
2311b6d
lib: rebase Assert.fail method
miguelmarcondesf Jun 6, 2025
9131e05
lib: enhance Assert class to support full diffs in error messages
miguelmarcondesf Jun 7, 2025
1c22af4
test: enhance assert.throws usage with nested assertion error handling
miguelmarcondesf Jun 8, 2025
00a293e
test: update assert throws stack out file
miguelmarcondesf Jun 8, 2025
0d3a968
test: align indentation in assert_throws_stack.out
miguelmarcondesf Jun 8, 2025
231f0c9
lib: convert Assert class to a constructor function type
miguelmarcondesf Jun 9, 2025
a5eb04c
test: add assertion for Assert constructor requiring new
miguelmarcondesf Jun 10, 2025
932b0a3
lib: bind assert methods to instance with correct name property
miguelmarcondesf Jun 10, 2025
42fb068
lib: enhance Assert constructor to validate options.diff
miguelmarcondesf Jun 10, 2025
74c90de
lib: simplify error handling with diff option
miguelmarcondesf Jun 10, 2025
a1db7bc
doc: add diff option to Assert and AssertionError
miguelmarcondesf Jun 10, 2025
2971f6c
doc: update version number for assert function introduction
miguelmarcondesf Jun 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions doc/api/assert.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ added: v0.1.21
* `operator` {string} The `operator` property on the error instance.
* `stackStartFn` {Function} If provided, the generated stack trace omits
frames before this function.
* `diff` {string} If set to `'full'`, shows the full diff in assertion errors. Defaults to `'simple'`.
Accepted values: `'simple'`, `'full'`.

A subclass of {Error} that indicates the failure of an assertion.

Expand Down Expand Up @@ -215,6 +217,29 @@ try {
}
```

## Class: assert.Assert

<!-- YAML
added: REPLACEME
-->

The `Assert` class allows creating independent assertion instances with custom options.

### `new assert.Assert([options])`

* `options` {Object}
* `diff` {string} If set to `'full'`, shows the full diff in assertion errors. Defaults to `'simple'`.
Accepted values: `'simple'`, `'full'`.

Creates a new assertion instance. The `diff` option controls the verbosity of diffs in assertion error messages.

```js
const { Assert } = require('node:assert');
const assertInstance = new Assert({ diff: 'full' });
assertInstance.deepStrictEqual({ a: 1 }, { a: 2 });
// Shows a full diff in the error message.
```

## `assert(value[, message])`

<!-- YAML
Expand Down
Loading
Loading