forcedotcom / LightningTestingService

Apache License 2.0
122 stars 35 forks source link

Test reporter not escaping results #87

Closed TuurDutoit closed 4 years ago

TuurDutoit commented 5 years ago

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).