Testing Frontend, Part 2
Testing Frontend, Part 2
Okay so yesterday we literally zoomed in and saw what the jest test object was. So let's find out some more. Okay so there are loads of methods. I think the best way to learn them will be to see them in action.
As there are so many of them - right? There are a few categories which might be a good place to start:
- Mock Modules
- Mock Functions
- Fake Timers
- Miscellaneous
- Of course not all of this makes sense to me - I mean I get mocking functions and I think I get fake timers
Expect
I feel like expect is going to be very similar to assert in pytest. Especially because I learned some jest before I ever learned any python.
So firstly there is just the initial expect - expect(value). You don't really call that alone. It says it is rare. I wonder when it would be. You are more like to have expect(returnAValue()).toBe(thatValue);
Hmmm.
Modifiers
You can also do some shit like expect(functionCall()).not.toBe('value')
And so on.
Matchers
Okay so I used these a bit yesterday - thanks. I am back again the next day after writing most of this blog post, and I have had a really great pairing sesh with my colleague. So everything makes a lot more sense now - thank you
And so I have a concept of what these matchers are. WHAT MY REALLY AMAZING COLLEAGUE SAID IS - TO USE THE DOCS TO TRY AND UNDERSTAND A TEST WHEN I SEE ONE. SO WHEN I SEE A NEW TEST THAT DOES NOT MAKE SENSE - I SHOULD CHECK THESE. THANKS. So there is no need to read them all at once.
But what about when I need to write a new test? How will I know what to put? And - what are asymmetric matchers?
Ah got it - they are when part of something needs to match.
But not all of it. React testing docs next...
.png)
Comments
Post a Comment