Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
test: add skipPrototypeComparison tests for Assert class
  • Loading branch information
miguelmarcondesf committed Sep 4, 2025
commit 5d5a6f83b966eb02d1d11c0e4d447fb03af84608
43 changes: 43 additions & 0 deletions test/parallel/test-assert-class.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,3 +478,46 @@ test('Assert class non strict with simple diff', () => {
);
}
});

// Shared setup for skipPrototypeComparison tests
{
const message = 'Expected values to be strictly deep-equal:\n' +
'+ actual - expected\n' +
'\n' +
' [\n' +
' 1,\n' +
' 2,\n' +
' 3,\n' +
' 4,\n' +
' 5,\n' +
'+ 6,\n' +
'- 9,\n' +
' 7\n' +
' ]\n';

function CoolClass(name) { this.name = name; }

function AwesomeClass(name) { this.name = name; }
const person = new CoolClass('Assert is inspiring');
const user = new AwesomeClass('Assert is inspiring');

test('Assert class strict with skipPrototypeComparison', () => {
const assertInstance = new Assert({ skipPrototypeComparison: true });

assert.throws(
() => assertInstance.deepEqual([1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 9, 7]),
{ message }
);
assertInstance.deepEqual(person, user);
});

test('Assert class non strict with skipPrototypeComparison', () => {
const assertInstance = new Assert({ strict: false, skipPrototypeComparison: true });

assert.throws(
() => assertInstance.deepStrictEqual([1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 9, 7]),
{ message }
);
assertInstance.deepStrictEqual(person, user);
});
}