-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
mark Runnable#retries and Runnable#currentRetry methods as public #4370
Conversation
This change makes it easier for Mocha reporters to report retriable and regular tests differently, should they choose to do so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need Runnable#retries()
and not Context#retries()
? Runnable
is essentially "abstract"...
The interface in use (e.g., bdd
) will call Context#retries()
, which should be fair game, and is probably erroneously marked @private
.
How are you accessing a Runnable
instance (or sub-pseudoclass-instance)?
Hey @boneskull, I need both Here's an example of how I use those APIs. So in my reporter: runner.on(Runner.constants.EVENT_TEST_RETRY, (test: Test, err: Error) => {
if (test.retries() >= 0) {
// do something with test.currentRetry();
}
}); I could move the change to interface visibility from However, I don't see Let me know which approach you prefer and I can update the PR. Thanks, |
OK, so that looks like a reporter. That example code should fail in parallel mode, since This is what you should do:
It's pretty obvious the combination setters/getters are problematic from an API surface standpoint. We really ought to reconsider all of them, because of problems like this and the lack of uniformity. |
Closing as an old and stale draft. Someone yell at me if this should be reopened. 🙂 |
This change makes it easier for Mocha reporters to report retriable and regular tests differently, should they choose to do so.
Description of the Change
I'd like the Serenity/JS Mocha reporter to be able to report differently on regular and retriable Mocha scenarios. In order to do so, a Mocha reporter needs to be able to tell the difference between the two.
The easiest way to do it is to mark the already existing
Runnable#retries
andRunnable#currentRetry
methods as public to expose the required information.Alternate Designs
Any alternative designs would require marking at least
Runnable#currentRetry
as public, so changing the JSDoc seems like the most efficient way to reach my objective.Why should this be in core?
This functionality can't be implemented in an external module.
Benefits
This change allows any Mocha reporter to treat retriable and regular scenarios differently and therefore provide better quality information to developers using them. If the PR makes it to core, I'm also planning to raise another one for
@types/mocha
Possible Drawbacks
Marking those APIs as public might encourage developers to use them in their tests, which they probably shouldn't be doing. Having said that, they can do that already.
Applicable issues
N/A