test: increase coverage for internal/error_serdes.js

test serializeError with getter property

Refs: https://coverage.nodejs.org/coverage-73a21e4c06d5781d/lib/internal/error_serdes.js.html#L49

PR-URL: https://github.com/nodejs/node/pull/36628
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
ZiJian Liu authored and Rich Trott committed 2020-12-27 21:04:20 -08:00
1 parent 0b6d3070a1
commit c27efd4e6b
1 file changed
+17
+17
View File
@@ -49,3 +49,20 @@ assert.strictEqual(cycle(Function), '[Function: Function]');
assert.strictEqual(err.name, 'TypeError');
assert.strictEqual(err.code, 'ERR_INVALID_ARG_TYPE');
}
{
let called = false;
class DynamicError extends Error {
get type() {
called = true;
return 'dynamic';
}
get shouldIgnoreError() {
throw new Error();
}
}
serializeError(new DynamicError());
assert.deepStrictEqual(called, true);
}