You have some errors in this code.
First, in Selection.prototype.expandFlightDetails be sure to get the first result of the array (you forgot [0] ):
document.getElementsByClassName("flight-details-container")[0]
Same comment for Selection.prototype.hideFlightDetails
Then, in your test case, you create an instance of Selection called selection , but then in both tests you use a variable called flightselection that is declared nowhere. Shouldn't it be selection ?
Finally, your problem is that you are trying to manipulate the 'flight-details-container' in your test, although this element is created in the afterEach . afterEach means that this will be done after each test, so it does not exist during the test.
source share