diff --git a/src/stringify.js b/src/stringify.js index 8ce427e..64b53bf 100644 --- a/src/stringify.js +++ b/src/stringify.js @@ -128,6 +128,7 @@ export function stringify(value, reducers) { `.get(${is_primitive(key) ? stringify_primitive(key) : '...'})` ); str += `,${flatten(key)},${flatten(value)}`; + keys.pop(); } str += ']'; diff --git a/test/test.js b/test/test.js index 8d336a2..1146d7a 100644 --- a/test/test.js +++ b/test/test.js @@ -571,6 +571,21 @@ for (const fn of [uneval, stringify]) { assert.equal(e.path, '.foo.map.get("key")'); } }); + + uvu.test(`${fn.name} populates error.path after maps (#64)`, () => { + try { + fn({ + map: new Map([['key', 'value']]), + object: { + invalid() {} + } + }); + } catch (e) { + assert.equal(e.name, 'DevalueError'); + assert.equal(e.message, 'Cannot stringify a function'); + assert.equal(e.path, '.object.invalid'); + } + }); } uvu.test('does not create duplicate parameter names', () => {