Skip to content

Commit

Permalink
feat: include file and line number on console errors
Browse files Browse the repository at this point in the history
closes searls#326
  • Loading branch information
Sven Johansson authored and klieber committed Aug 24, 2022
1 parent 123ba81 commit bcb614d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
<script type="application/javascript">
window.onerror = function(msg, url, line) {
var errors = window.consoleErrors = window.consoleErrors || [];
errors.push(msg);
errors.push(msg + ' (' + url + ':' + line + ')');
};

function getConsoleErrors() {
var errors = [];
if (jsApiReporter && jsApiReporter.runDetails && jsApiReporter.runDetails.failedExpectations) {
errors = jsApiReporter.runDetails.failedExpectations.map((error) => error.message);
errors = jsApiReporter.runDetails.failedExpectations
.map((error) => error.message + ' (' + error.filename + ':' + error.lineno + ')');
}

if (errors.length === 0) {
Expand Down
5 changes: 3 additions & 2 deletions src/main/resources/jasmine-templates/SpecRunner.htmltemplate
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
<script type="application/javascript">
window.onerror = function(msg, url, line) {
var errors = window.consoleErrors = window.consoleErrors || [];
errors.push(msg);
errors.push(msg + ' (' + url + ':' + line + ')');
};

function getConsoleErrors() {
var errors = [];
if (jsApiReporter && jsApiReporter.runDetails && jsApiReporter.runDetails.failedExpectations) {
errors = jsApiReporter.runDetails.failedExpectations.map((error) => error.message);
errors = jsApiReporter.runDetails.failedExpectations
.map((error) => error.message + ' (' + error.filename + ':' + error.lineno + ')');
}

if (errors.length === 0) {
Expand Down

0 comments on commit bcb614d

Please sign in to comment.