From 7d250fa9cfb30f95e7af523720b66c8b001df15c Mon Sep 17 00:00:00 2001 From: Maribeth Bottorff Date: Mon, 7 Mar 2022 18:55:11 -0800 Subject: [PATCH] feat: add mocha failure messages to console output (#5984) * feat: add mocha failure messages to console output * fix: line up the messages --- tests/mocha/index.html | 10 ++++++++-- tests/mocha/run_mocha_tests_in_browser.js | 12 +++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/tests/mocha/index.html b/tests/mocha/index.html index d4d40331441..694d5215aac 100644 --- a/tests/mocha/index.html +++ b/tests/mocha/index.html @@ -18,9 +18,9 @@ } -
+ @@ -173,10 +173,16 @@ diff --git a/tests/mocha/run_mocha_tests_in_browser.js b/tests/mocha/run_mocha_tests_in_browser.js index d4dc83fbe5e..217c9992bc6 100644 --- a/tests/mocha/run_mocha_tests_in_browser.js +++ b/tests/mocha/run_mocha_tests_in_browser.js @@ -61,8 +61,18 @@ async function runMochaTestsInBrowser() { const elem = await browser.$('#failureCount'); const numOfFailure = await elem.getAttribute('tests_failed'); + if (numOfFailure > 0) { + console.log('============Blockly Mocha Test Failures================') + const failureMessagesEls = await browser.$$('#failureMessages p'); + if (!failureMessagesEls.length) { + console.log('There is at least one test failure, but no messages reported. Mocha may be failing because no tests are being run.'); + } + for (let el of failureMessagesEls) { + console.log(await el.getText()); + } + } + console.log('============Blockly Mocha Test Summary================='); - console.log(numOfFailure); console.log(numOfFailure + ' tests failed'); console.log('============Blockly Mocha Test Summary================='); if (parseInt(numOfFailure) !== 0) {