8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5eb5d1d commit a9ab28dCopy full SHA for a9ab28d
lib/internal/assert.js
@@ -56,7 +56,9 @@ function inspectValue(val) {
56
breakLength: Infinity,
57
// Assert does not detect proxies currently.
58
showProxy: false,
59
- sorted: true
+ sorted: true,
60
+ // Inspect getters as we also check them when comparing entries.
61
+ getters: true
62
}
63
);
64
test/parallel/test-assert-deep.js
@@ -24,7 +24,8 @@ function re(literals, ...values) {
24
customInspect: false,
25
maxArrayLength: Infinity,
26
27
28
29
});
30
// Need to escape special characters.
31
result += str;
@@ -1049,3 +1050,24 @@ assert.throws(
1049
1050
1051
assertDeepAndStrictEqual(a, b);
1052
1053
+
1054
+// Check getters.
1055
+{
1056
+ const a = {
1057
+ get a() { return 5; }
1058
+ };
1059
+ const b = {
1060
+ get a() { return 6; }
1061
1062
+ assert.throws(
1063
+ () => assert.deepStrictEqual(a, b),
1064
+ {
1065
+ code: 'ERR_ASSERTION',
1066
+ name: 'AssertionError [ERR_ASSERTION]',
1067
+ message: /a: \[Getter: 5]\n- a: \[Getter: 6]\n /
1068
+ }
1069
+ );
1070
1071
+ // The descriptor is not compared.
1072
+ assertDeepAndStrictEqual(a, { a: 5 });
1073
+}