Ask coding questions

← Back to all posts
Creating unit tests for DOM manipulation using jest in teams for education testing UI
harsha3195 (0)

I would like to know if there is a way for me to write unit tests for JS code that manipulates some DOM elements. for example, tests for js code that adds elements to an existing HTML list. Something like: this

I am able to create these tests outside of the replit teams for education testing UI and run them through shell (jest), by using JSDOM as the testing environment, but am unable to find how I can change the testing environment for the replit testing UI in replit( language = node ).

Using it via testing UI would enable my students to run tests via pressing a button, and reflect the results in overview, so I would love to be able to do this.

Would love help on this!

Thanks in advance!

ch1ck3n (2088)

no there is no built-in unit tests for HTML repls

harsha3195 (0)

@ch1ck3n Yeah, I used a node repl and then created an express server there to host HTML pages.

ch1ck3n (2088)

@harsha3195 ohh now i know what you're talking about

no you cant

I don't think jest is supportted

harsha3195 (0)

@ch1ck3n The docs mention it! I think jest is supported for node :\

ch1ck3n (2088)

@harsha3195 oh.. im sorry if i confused you but now I think your right