From d0aa7baaca291a50dcb8243aeeea8bfd103fdba2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Kapalla?= Date: Sun, 29 Apr 2018 02:39:16 +0200 Subject: [PATCH] fix(common): stringify error on 'Cannot convert a Symbol value to a string' Fixes #2856 --- common/stringify.js | 2 ++ test/client/stringify.spec.js | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/common/stringify.js b/common/stringify.js index 192a4847a..aece384d3 100644 --- a/common/stringify.js +++ b/common/stringify.js @@ -14,6 +14,8 @@ var stringify = function stringify (obj, depth) { } switch (typeof obj) { + case 'symbol': + return obj.toString() case 'string': return "'" + obj + "'" case 'undefined': diff --git a/test/client/stringify.spec.js b/test/client/stringify.spec.js index e51c85d37..19bceab4e 100644 --- a/test/client/stringify.spec.js +++ b/test/client/stringify.spec.js @@ -4,6 +4,10 @@ var assert = require('assert') var stringify = require('../../common/stringify') describe('stringify', function () { + it('should serialize symbols', function () { + assert.deepEqual(stringify(Symbol.for('x')), 'Symbol(x)') + }) + it('should serialize string', function () { assert.deepEqual(stringify('aaa'), "'aaa'") })