JavaScript: More testing section is hard to understand #26882
Replies: 4 comments
-
I agree that mocking could be confusing. I'd love to see some ways to improve that content by providing an example that people can code along with in our own lesson. Perhaps someone more comfortable with testing from the @TheOdinProject/javascript has some ideas that we can open up for a contributor? |
Beta Was this translation helpful? Give feedback.
-
This video from Codete on Jest mocking might help. It's concise and straight to the point. There's also this article on Medium which explains Jest mocking |
Beta Was this translation helpful? Give feedback.
-
I would love to see an improvement to the mocking explanation. I found understanding the explanation about why we need testing and what a mock is fairly straight forward but more resources on how they work would be welcome |
Beta Was this translation helpful? Give feedback.
-
This issue is stale because it has had no activity for the last 30 days. |
Beta Was this translation helpful? Give feedback.
-
Maybe it's just me but I'm having a hard time understanding jest mocks. I've read every resource carefully but I'm still unable to understand them. Like how do I actually put them in practice? I'm trying to use them for Battleship project which is the last one in JavaScript course but I just couldn't understand. For example (the code is from jest: Mock Functions):
when I run the test both in js and ts, I get error axios.get.mockResolvedValue is not a function (I installed the package btw).
Like what is jest.mock() actually doing? I don't get it and how to prevent this error? I tried googling but no luck.
Also how to mock for example, fetch api or console.log for testing? It's not clear how to mock such stuff with side effects.
This section should probably contain some resources to practice these skills or at least simplify mocking.
Path
Node / JS
Lesson Url
https://www.theodinproject.com/lessons/node-path-javascript-more-testing
Checks
Beta Was this translation helpful? Give feedback.
All reactions