Skip to content

fix: updated mocha tests to display error messages#7706

Merged
maribethb merged 2 commits into
RaspberryPiFoundation:developfrom
btw17:fix/mocha-test-failure-messages
Dec 8, 2023
Merged

fix: updated mocha tests to display error messages#7706
maribethb merged 2 commits into
RaspberryPiFoundation:developfrom
btw17:fix/mocha-test-failure-messages

Conversation

@btw17

@btw17 btw17 commented Dec 8, 2023

Copy link
Copy Markdown
Contributor

The basics

The details

Resolves

Fixes #7649

Proposed Changes

Instead of using getText(), which requires a visible element, I use getHTML() and strip out the p tag.
- See https://webdriver.io/docs/api/element/getText and note: only visible elements will return display.
- The root element with id failureCount has display: none, so the text content here never displays.

Previous output:

Loading URL: file:///usr/local/google/home/blaketw/git/blockly/blockly/tests/mocha/index.html
============Blockly Mocha Test Failures================

============Blockly Mocha Test Summary=================
1 tests failed
============Blockly Mocha Test Summary=================
Mocha tests failed

Updated output:

Loading URL: file:///usr/local/google/home/blaketw/git/blockly/blockly/tests/mocha/index.html
============Blockly Mocha Test Failures================
"Comments Set/Get Bubble Size Set Size While Invisible" failed: expected 100 to equal 101
============Blockly Mocha Test Summary=================
1 tests failed
============Blockly Mocha Test Summary=================
Mocha tests failed

Reason for Changes

To resolve #7649

Test Coverage

N/A

Documentation

N/A

Additional Information

  • Not sure if #failureCount was previously visible, though another way to mitigate this would be to set it visible

@btw17 btw17 requested a review from a team as a code owner December 8, 2023 20:16
@btw17 btw17 requested a review from cpcallen December 8, 2023 20:16
@github-actions github-actions Bot added PR: fix Fixes a bug and removed PR: fix Fixes a bug labels Dec 8, 2023
Comment thread tests/mocha/webdriver.js Outdated
for (const el of failureMessagesEls) {
console.log(await el.getText());
const messageHtml = await el.getHTML();
console.log(messageHtml.replace("<p>", "").replace("</p>", ""));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could you replace the double quotes with single quotes? it appears we don't format this file but that would match the rest of the file. Thanks!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@BeksOmega BeksOmega assigned maribethb and unassigned cpcallen Dec 8, 2023
@BeksOmega BeksOmega requested review from maribethb and removed request for cpcallen December 8, 2023 21:18
@maribethb maribethb merged commit 3e75f4f into RaspberryPiFoundation:develop Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: fix Fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mocha test failures not reported by test/mocha/webdriver.js

3 participants