Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: updated mocha tests to display error messages #7706

Merged
merged 2 commits into from
Dec 8, 2023

Conversation

btw17
Copy link
Member

@btw17 btw17 commented Dec 8, 2023

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
@@ -63,7 +63,8 @@ async function runMochaTestsInBrowser() {
console.log('There is at least one test failure, but no messages reported. Mocha may be failing because no tests are being run.');
}
for (const el of failureMessagesEls) {
console.log(await el.getText());
const messageHtml = await el.getHTML();
console.log(messageHtml.replace("<p>", "").replace("</p>", ""));
Copy link
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
Member 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 google:develop Dec 8, 2023
6 checks passed
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