var norm
line, select Run to cursor, and then step over or through the call to normalizeData
. Coming back from that and hovering over the name
variable, we can see that it contains exactly what we’d expect, including a truncated name
property:norm.Name
instead of norm.name
(lowercase n on name), which is why the failure report said that the Actual value given to the expect
assertion was undefined
. It’s a simple mistake, but one that could be confusing if we didn’t carefully examine the failure report and check the code in the debugger.norm.Name
to norm.name
, saving normalize_tests.js
, and rerunning the test, we find that it now passes.JSON.parse
where a leading zero on an integer value is concerned. These two tests are the ones that use such leading zeros:JSON.parse
is OK with these, and treats the value as an integer. The implementation in PhantomJS, on the other hand, throws an exception, which is why normalizeData
returned null
.normalizeData
method can't work both ways, so we have to make them consistent.