diff --git a/papaparse.js b/papaparse.js index 94317709..d04eaaeb 100755 --- a/papaparse.js +++ b/papaparse.js @@ -1364,12 +1364,15 @@ License: MIT function addError(type, code, msg, row) { - _results.errors.push({ + var error = { type: type, code: code, - message: msg, - row: row - }); + message: msg + }; + if(row !== undefined) { + error.row = row; + } + _results.errors.push(error); } } diff --git a/tests/test-cases.js b/tests/test-cases.js index 58a85f08..608b2978 100644 --- a/tests/test-cases.js +++ b/tests/test-cases.js @@ -592,7 +592,7 @@ describe('Core Parser Tests', function() { function generateTest(test) { (test.disabled ? it.skip : it)(test.description, function() { var actual = new Papa.Parser(test.config).parse(test.input); - assert.deepEqual(JSON.stringify(actual.errors), JSON.stringify(test.expected.errors)); + assert.deepEqual(actual.errors, test.expected.errors); assert.deepEqual(actual.data, test.expected.data); }); } @@ -1475,7 +1475,7 @@ describe('Parse Tests', function() { if (test.expected.meta) { assert.deepEqual(actual.meta, test.expected.meta); } - assert.deepEqual(JSON.stringify(actual.errors), JSON.stringify(test.expected.errors)); + assert.deepEqual(actual.errors, test.expected.errors); assert.deepEqual(actual.data, test.expected.data); }); } @@ -1556,7 +1556,7 @@ describe('Parse Async Tests', function() { var config = test.config; config.complete = function(actual) { - assert.deepEqual(JSON.stringify(actual.errors), JSON.stringify(test.expected.errors)); + assert.deepEqual(actual.errors, test.expected.errors); assert.deepEqual(actual.data, test.expected.data); done(); }; @@ -2384,7 +2384,7 @@ describe('Custom Tests', function() { this.timeout(test.timeout); } test.run(function(actual) { - assert.deepEqual(JSON.stringify(actual), JSON.stringify(test.expected)); + assert.deepEqual(actual, test.expected); done(); }); });