I have 5+ years of experience with JavaScript, 3+ with React. Proficient in web technologies such as JavaScript, React, Redux, and React Query, HTML5 CSS3, SASS, SQL, Ruby, Ruby on Rails.
Mocking is a code smell. I will explain why.
If, for some reason, history changes the method name from push to gotoPath the test will pass because the function is mocked but the code will be broken.
Also the test does not test if it actually goes to the url /home, actually it tests if the mocked function is called with /home
How do you write unit tests without mocking ever? Surely if you have to include every dependency all the time you're going to end up writing integration tests no?
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Mocking is a code smell. I will explain why.
If, for some reason, history changes the method name from
push
togotoPath
the test will pass because the function is mocked but the code will be broken.Also the test does not test if it actually goes to the url
/home
, actually it tests if the mocked function is called with/home
How do you write unit tests without mocking ever? Surely if you have to include every dependency all the time you're going to end up writing integration tests no?