The test reporter in lts_testutil doesn't escape HTML entities in the test results before writing them to the innerHTML of the run_results_full div. This means that any special characters present in this JSON data - which can come from the names of the tests, for example - will be parsed by the browser.
For example, if I define a test like the following: it('produces a <div>', function(){...}), the <div> part will be parsed by the browser, into an actual div element. As long as the original innerHTML doesn't change, this wouldn't cause problems for the CLI when parsing the content. Unfortunately, browsers are very lenient when parsing HTML and will add a closing </div> at the end of the data, breaking the JSON.parse() step performed by the CLI (in salesforce-alm/dist/lib/lightning/lightningTestApi.js).
The test reporter in lts_testutil doesn't escape HTML entities in the test results before writing them to the innerHTML of the run_results_full div. This means that any special characters present in this JSON data - which can come from the names of the tests, for example - will be parsed by the browser.
For example, if I define a test like the following:
it('produces a <div>', function(){...})
, the<div>
part will be parsed by the browser, into an actualdiv
element. As long as the original innerHTML doesn't change, this wouldn't cause problems for the CLI when parsing the content. Unfortunately, browsers are very lenient when parsing HTML and will add a closing</div>
at the end of the data, breaking theJSON.parse()
step performed by the CLI (insalesforce-alm/dist/lib/lightning/lightningTestApi.js
).