This is a basic example of what my code essentially does.var gender; function setGender(genderVal) { gender = genderVal; } function isMale() { if(gender == "male") { return true; } else { return false; } } module.exports = { setGender: setGender, isMale: isMale } If I try to test the isMale() function, I get an error because gender is not set. How can I mock the gender variable? I'm not new to JS, but very new to ES6 and all of the weird and wonderful things that come with it. Please excuse my slowness in adoption. The code I'm trying to test is just a bunch of functions, no classes or anything like that. Not sure if that's part of my problem.Any guidance here would be appreciated!
Submitted February 18, 2020 at 03:43PM by Mirror_rorriM_Mirror
No comments:
Post a Comment