Skip to content

🚀 Feature: Overloading consoleLog in reporters.Base for custom reporter #4971

Open
@chengB12

Description

When creating custom reporter, and to utilize reporters.Base functions, it is best to extends reporter.Base function.

However, mocha doesn't provide type-safe (for typescript) way to overload consoleLog function, since many of reporter.Base functions are directly call Base.consoleLog function. it would be better to overload it if we don't want it print them to console

I found I can force overload it through

(Mocha.reporters.Base as any).consoleLog = (...data: any[]) => {
    // do my own logging
}

However, I feel this is undocumented and unexposed to @types/mocha, so it is subjected to change and breaks code above

can we have declared way to overload that method, ideally like

class MyReporter extends Mocha.reporters.base {
    override consoleLog(... data) {
        // my own logging
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    status: blockedWaiting for something else to be resolvedtype: featureenhancement proposal

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions