Node.js assert.doesNotReject() Function Last Updated : 14 May, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report The assert.doesNotReject() method is used to check if the given promise is not rejected. If the provided parameter is a Promise, it is awaited; if it is a function, it is called immediately and the returning Promise is awaited. Syntax: assert.doesNotReject(asyncFn[, error][, message]) Parameters: asyncFn: An asynchronous function or a Promise which is to be checked.error: It is the specified error. It might be a regular expression or a function. This is optional.message: The error message of string or error type. This is optional. Return Value: It returns a rejected Promise. Example 1: JavaScript import assert from 'node:assert/strict'; await assert.doesNotReject( async () => { await new Promise(resolve => setTimeout(resolve, 5000)); console.log("Hello"); }, SyntaxError ); Output: Hello Example 2: JavaScript import assert from 'node:assert/strict'; function resolved(result) { console.log('Resolved'); } function rejected(result) { console.error(result); } await assert.doesNotReject( Promise.reject(new Error('fail')).then(resolved, rejected), SyntaxError ); Output: Reference: https://nodejs.org/api/assert.html#assertdoesnotrejectasyncfn-error-message Comment More infoAdvertise with us Next Article Node.js assert() Function A aayushmohansinha Follow Improve Article Tags : Web Technologies Node.js Node.js-Methods NodeJS-assert Similar Reads Node.js assert.doesNotThrow() Function The assert module provides a set of assertion functions for verifying invariants. The assert.doesNotThrow() function asserts that the function fn does not throw an error. Syntax: assert.doesNotThrow(fn[, error][, message]) Parameters: This function accepts the following parameters as mentioned above 3 min read Node.js assert.doesNotMatch() Function The assert module provides a set of assertion functions for verifying invariants. The assert.doesNotMatch() function expects the string input not to match the regular expression. If the condition is true it will not produce an output else an assertion error is raised. Syntax: assert.doesNotMatch(st 2 min read Node.js assert.deepStrictEqual() Function The assert module provides a set of assertion functions for verifying invariants. The assert.deepStrictEqual() function tests for deep equality between the actual and expected parameters. If the condition is true it will not produce an output else an assertion error is raised. Syntax: assert.deepStr 2 min read Node.js assert.deepEqual() Function The assert module provides a set of assertion functions for verifying invariants. The assert.deepEqual() function tests deep equality between the actual and the expected parameters. If the condition is true it will not produce an output else an assertion error is raised. Syntax: assert.deepEqual(act 2 min read Node.js assert() Function The assert() function in Node.js is used for testing and verifying assumptions in your code. It is part of the built-in assert module, which provides a set of assertion functions to perform various checks and validations.Node assert FunctionIn assert() function, if the value is not truth, then a Ass 3 min read Node.js assert.equal() Function The assert module provides a set of assertion functions for verifying invariants. The assert.equal() function tests for equality between the actual and the expected parameters. If the condition is true it will not produce an output else an assertion error is raised. Syntax: assert.equal(actual, exp 2 min read Like