Repository navigation
fix(nightwatch-devtools): report passing tests without Nightwatch assertions as passed - #468
Conversation
[Medium impact] The PR appears safe to merge; no blocking issues were found. SummaryUpdates Nightwatch test results so completed tests without Nightwatch assertions report passed, while tests with errors report failed.
Reviews (3) · Last reviewed commit: "Merge origin/main into fix/nightwatch-pa..." · Reviewed by Greptile |
vishnuv688
left a comment
There was a problem hiding this comment.
Thanks for this, the fix is correct and the right size. I checked it against Nightwatch 3.16's reporter (lib/reporter/results.js): a test only gets a results.testcases entry from setCurrentTest, when it actually runs, and tests skipped by the user or at runtime are tracked in separate lists. So passed: 0, failed: 0 really is a test that ran without a Nightwatch assertion, and reporting it passed is right. Counting errors > 0 as failed is a good catch too. The new cases cover the regression.
A few small things before merge:
- Drop the
?? 0guards.NightwatchTestCasetypeserrorsandskippedas required numbers, andcreateTestCaseResultsalways sets both to 0. Guarding those two but notpassed/failedsuggests they can be missing when neither the type nor Nightwatch says so. Plaintestcase.errors > 0andtestcase.skipped > 0read better. - The
skippedbranch is unreachable in practice. Nightwatch never increments the per-testcaseskippedcounter, so a real skip is decided by the callers that find no testcase entry (closePreviousTest.ts,test-lifecycle.ts), not here. Keeping it as a defensive branch is fine, or you could drop it so the function is just failed-or-errors, else passed. Either way, the description shouldn't suggest this function now handles skips. - Changeset wording: we write changesets as current behaviour rather than before/after, and leave out internal counters. Something like: "A Nightwatch test that makes no Nightwatch assertion is reported as passed, and one with errors as failed."
- Optional test: a case with
errors > 0alongsidepassed > 0, to pin that a failure wins.
Did you get a chance to run it against examples/nightwatch (a test with only node:assert, or no assertions, showing green in the dashboard sidebar)? If not, mentioning that in the PR description is enough. Our cross-adapter conformance suite (packages/conformance) currently allowlists this bug as a known gap, so once this merges that gap will be reported stale and we'll remove it on our side.
|
One correction to my last point: since #465 merged, main's conformance suite (part of |
b45d853 to
5fcffc9
Compare
|
Thanks for the detailed review @vishnuv688! Rebased onto
|
Resolved against main: the #459 gap was the last user of reportedAs and of the REFUSED scenario title, so both go, and failureUnexplained no longer exists on main.
|
Thanks for the quick turnaround, @hoanle0126, every review point is addressed. Main moved on after this opened (#473, #474 and #475 changed the same conformance files), so I merged main into your branch in 4ba4f23 rather than ask you to. Your two commits are untouched. The resolution: with the #459 gap gone, I also checked that your change is what the suite now relies on: with |
|
@hoanle0126 Let me know if there is no other changes I will merge this PR. |
|
No other changes from my side, it's ready to merge. Thanks @vishnuv688! |
…the page's load time Main fixed Nightwatch reporting passing tests as skipped (#468), so the skipped gap this branch extended to the page-title test goes, with its debt entry and CLAUDE.md bullet; the service gap for #481 stays. The timings rule accepted any navigation entry, so an empty object passed. It now requires the load time the fake page reports, so a capture that drops its timing figures fails.
What & why
Fixes #459
In Nightwatch,
testcase.passedandtestcase.failedcount Nightwatchbrowser.assert.*/browser.verify.*assertions inside that testcase. When a test runs and finishes without making a Nightwatch assertion (or usesnode:assert), Nightwatch records{ passed: 0, failed: 0, errors: 0, skipped: 0 }inresults.testcases.Previously,
determineTestState(testcase)checkedif (testcase.passed === 0 && testcase.failed === 0) return 'skipped', which marked any passing test without Nightwatch assertions asskipped(and also ignoredtestcase.errors).This updates
determineTestState(testcase)to return'failed'whentestcase.failed > 0 || testcase.errors > 0and'passed'for completed testcases without Nightwatch assertions, and removes theKNOWN_DEBT.nightwatchSkippedconformance allowlist entry.Type of change
Packages touched
shared(types and contracts)core(framework-agnostic capture/reporting)elements(published element/snapshot API —@wdio/elements)service(WebdriverIO adapter)nightwatch-devtools(Nightwatch adapter)selenium-devtools(Selenium adapter)selenium-devtools-py(Selenium Python adapter)backend(server)app(UI)script(page-injected runtime)trace(Trace mode)Notes for reviewers
packages/nightwatch-devtools/tests/utils.test.ts({ passed: 0, failed: 0, errors: 0, skipped: 0 } → 'passed',{ passed: 0, failed: 0, errors: 1, skipped: 0 } → 'failed', and{ passed: 1, failed: 0, errors: 1, skipped: 0 } → 'failed') and removedKNOWN_DEBT.nightwatchSkippedfrompackages/conformance.examples/nightwatchin a live browser; validated via the unit tests and the conformance suite (RULES.testsAsDesigned).