diff --git a/Userland/Libraries/LibJS/Tests/test-common.js b/Userland/Libraries/LibJS/Tests/test-common.js index 3c0eec4f11..9141fbe53c 100644 --- a/Userland/Libraries/LibJS/Tests/test-common.js +++ b/Userland/Libraries/LibJS/Tests/test-common.js @@ -51,7 +51,14 @@ class ExpectationError extends Error { return true; }; - const valueToString = value => Object.prototype.toString.call(value); + const valueToString = value => { + try { + return String(value); + } catch { + // e.g for objects without a prototype, the above throws. + return Object.prototype.toString.call(value); + } + }; class Expector { constructor(target, inverted) {