Skip to content

🐛 Bug: Browser reporter suite unhide is broken (only unhides half the suites) #2893

Open

Description

Found out exactly what's going on in #2754: the HTMLCollection returned by document.getElementsByClassName, at least in some browsers, actually drops elements that get their className changed such that they no longer match the criteria on which the collection was based; thus, Mocha will only unhide the first half of the hidden suites or every other one of them.

#2754 attempted to fix this by converting the collection to an array. Currently Mocha runs in some pretty old environments. If we have a shim for the array slice method we should use that rather than assuming the native [].slice. If we don't have such a shim, we should simply reverse the for loop: start at .length - 1 and decrement while >= 0 instead of starting at 0 and incrementing while < .length.

(We should also get a test for the unhiding of more than one suite. I will incorporate this into my work on testing the HTML reporter and mark it as .skip until a fix can also be PR'd.)

I'd like to thank @ZeroBinbin for bringing this to our attention, and apologize for taking so long to get around to digging into it.

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

Metadata

Assignees

No one assigned

    Labels

    area: browserbrowser-specificarea: reportersinvolving a specific reporterstatus: accepting prsMocha can use your help with this one!type: buga defect, confirmed by a maintainer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions