I have been trying to get tests 17-24 on this lab to pass for like 2 days straight. I have tried several alternative approaches including the forum post where the guy recommended using document.createElement(‘div’) for each motorcycle card. But it seems that nothing can get them to pass, even adding an initial delay before the data fetch/render. It seems like nobody else is able to get these tests passing either.
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36
This is weird, and I’m not entirely sure why it makes difference. Tests are passing, when there’s added check in renderMotorcycles to make sure this.allMotorcycles are not empty. It can be also in form of checking if cardsHtml is falsey.
satisfy this, then all the test cases will pass. worked for me. because the assertion test cases are written to check this way. this means, the fetch, filtering all should happen inside the renderMotorcycles function.
for every test case from 17 to 24 new class instance is created. and render function is invoked. so, everytime a new instance is created, the data should be fetched and ready. then render happens. after that assertion test will check if there required number of elements with that specific class are there in the document or not.
I initially had an initGallery() function in my class to display the original 25 motorcycles but simply changing it to renderMotorcycles() helped me pass all the tests. Thank you @vishnurvp2