mardi 26 janvier 2021

Using jquery $(this) with jest when manipulating the dom

I am using jest to try and test some form validation that uses javascript and jQuery.

I pass in the html I want to test in my test file with document.body.innerHTML = "<form>[form stuff]</form>, then I call the validation function with foo.check($(this)). This works in my application but i get jQuery { '0': {}, length: 1 } when I run the function from the test file and console.log the $(this) from within the function.

Is there something extra I need to do, to be able to pass my form into the function from the test?

Aucun commentaire:

Enregistrer un commentaire