WEBVTT

1
00:00:00.000 --> 00:00:02.080
<v Speaker 1>All right, everyone, get ready for this. We're diving deep

2
00:00:02.080 --> 00:00:05.879
<v Speaker 1>today into React Testing Library RTL. If you want to

3
00:00:05.919 --> 00:00:06.759
<v Speaker 1>sound cool.

4
00:00:06.639 --> 00:00:07.200
<v Speaker 2>Uh huh.

5
00:00:07.280 --> 00:00:07.719
<v Speaker 1>Yeah.

6
00:00:07.960 --> 00:00:10.439
<v Speaker 2>When we say cool, we really mean developers who are

7
00:00:10.560 --> 00:00:13.679
<v Speaker 2>you know, serious about building React apps that are like

8
00:00:13.960 --> 00:00:17.839
<v Speaker 2>actually good, robust, user friendly.

9
00:00:17.600 --> 00:00:20.280
<v Speaker 1>All that for sure, And we've got an awesome guide

10
00:00:20.280 --> 00:00:23.760
<v Speaker 1>for this deep dive. Simplified Testing with React Testing Library

11
00:00:24.280 --> 00:00:26.559
<v Speaker 1>by Scotty Crump. Really a game changer.

12
00:00:26.839 --> 00:00:29.719
<v Speaker 2>Absolutely. It's not just about you know, going through the

13
00:00:29.760 --> 00:00:33.200
<v Speaker 2>motions with testing. It's about making tests that matter that

14
00:00:33.399 --> 00:00:37.039
<v Speaker 2>focus on how like real people are going to use

15
00:00:37.079 --> 00:00:37.920
<v Speaker 2>the thing you built.

16
00:00:38.000 --> 00:00:40.000
<v Speaker 1>So let's about getting lost in all the code details

17
00:00:40.000 --> 00:00:43.280
<v Speaker 1>and more about thinking like a user would clicking buttons,

18
00:00:43.399 --> 00:00:44.560
<v Speaker 1>using forms, that sort of thing.

19
00:00:44.679 --> 00:00:47.039
<v Speaker 2>Exactly. It's like imagine you're building a car. You wouldn't

20
00:00:47.079 --> 00:00:49.320
<v Speaker 2>just test that the engine turns on right, You'd want

21
00:00:49.320 --> 00:00:51.320
<v Speaker 2>to actually drive it, make sure the brakes work, the

22
00:00:51.359 --> 00:00:52.159
<v Speaker 2>steering wheel.

23
00:00:51.960 --> 00:00:55.240
<v Speaker 1>Does its job, Yeah, the seats are comfy, the whole experience.

24
00:00:55.000 --> 00:00:58.520
<v Speaker 2>Exactly, because that's what matters the driver's experience. And that's

25
00:00:58.560 --> 00:01:02.520
<v Speaker 2>the philosophy behind RTL. Well testing from the user's perspective,

26
00:01:02.560 --> 00:01:05.079
<v Speaker 2>making sure that your React apps aren't just functional but

27
00:01:05.280 --> 00:01:06.599
<v Speaker 2>actually enjoyable to use.

28
00:01:06.760 --> 00:01:09.319
<v Speaker 1>Okay, I'm with you on the philosophy, but what about

29
00:01:09.359 --> 00:01:12.799
<v Speaker 1>the actual tools and techniques What makes RTL stand out.

30
00:01:13.000 --> 00:01:15.560
<v Speaker 2>So one of the key parts is just it's a

31
00:01:15.640 --> 00:01:20.480
<v Speaker 2>JavaScript testing framework that's become like the industry standard for React.

32
00:01:20.560 --> 00:01:23.040
<v Speaker 2>It gives you a really solid environment for running those

33
00:01:23.040 --> 00:01:25.319
<v Speaker 2>tests and it works perfectly with RTL.

34
00:01:25.400 --> 00:01:28.040
<v Speaker 1>And then there's this thing called the screen object right,

35
00:01:28.239 --> 00:01:30.079
<v Speaker 1>which is kind of like a direct link to your

36
00:01:30.120 --> 00:01:30.799
<v Speaker 1>apps UI.

37
00:01:31.040 --> 00:01:33.480
<v Speaker 2>Yeah, think of it like x ray vision into your app.

38
00:01:33.519 --> 00:01:36.000
<v Speaker 2>You can find elements on the page the same way

39
00:01:36.040 --> 00:01:38.280
<v Speaker 2>a user would by their role, the text on them,

40
00:01:38.280 --> 00:01:38.840
<v Speaker 2>stuff like that.

41
00:01:38.959 --> 00:01:42.879
<v Speaker 1>So no more relying on those internal IDs or classes

42
00:01:42.920 --> 00:01:45.680
<v Speaker 1>that could break your tests. That the code changes exactly.

43
00:01:45.840 --> 00:01:48.400
<v Speaker 2>And when it comes to user interactions, RTL takes it

44
00:01:48.439 --> 00:01:51.439
<v Speaker 2>a step further. With the user event module, you can

45
00:01:51.519 --> 00:01:55.519
<v Speaker 2>actually simulate real user actions type being clicking, selecting. Makes

46
00:01:55.519 --> 00:01:57.120
<v Speaker 2>your test super realistic.

47
00:01:57.319 --> 00:01:59.760
<v Speaker 1>So instead of just checking if a button exists, you

48
00:01:59.799 --> 00:02:02.359
<v Speaker 1>can test what happens when a user clicks it, how

49
00:02:02.400 --> 00:02:05.599
<v Speaker 1>the UI changes, how the app reacts, all that. It's

50
00:02:05.599 --> 00:02:06.760
<v Speaker 1>like having a robot.

51
00:02:06.480 --> 00:02:10.159
<v Speaker 2>User huh huh exactly. And remember that car analogy. Well,

52
00:02:10.479 --> 00:02:13.639
<v Speaker 2>when you're testing components that depend on libraries like Redux,

53
00:02:14.080 --> 00:02:16.319
<v Speaker 2>it's like trying to test the engine while it's still

54
00:02:16.319 --> 00:02:19.520
<v Speaker 2>hooked up to the transmission. Custom render methods are how

55
00:02:19.520 --> 00:02:22.159
<v Speaker 2>we get around that. They let us isolate the component

56
00:02:22.240 --> 00:02:23.240
<v Speaker 2>and test it properly.

57
00:02:23.400 --> 00:02:26.000
<v Speaker 1>That's a brilliant analogy. So custom render methods are like

58
00:02:26.039 --> 00:02:28.039
<v Speaker 1>setting up a little test lab where you can control

59
00:02:28.039 --> 00:02:31.159
<v Speaker 1>the environment and see how your components react exactly.

60
00:02:31.639 --> 00:02:35.039
<v Speaker 2>And this brings us to another important concept, the difference

61
00:02:35.080 --> 00:02:38.759
<v Speaker 2>between integration testing and isolation testing.

62
00:02:38.879 --> 00:02:41.919
<v Speaker 1>Now, this is where things get interesting. So integration testing

63
00:02:42.120 --> 00:02:44.879
<v Speaker 1>is like looking at the big picture seeing how all

64
00:02:44.919 --> 00:02:47.560
<v Speaker 1>the parts of your app work together, and isolation testing

65
00:02:47.639 --> 00:02:49.520
<v Speaker 1>is kind of like zooming in on a single piece.

66
00:02:49.719 --> 00:02:52.240
<v Speaker 2>Yeah, exactly. The book Use is a great example a

67
00:02:52.319 --> 00:02:55.960
<v Speaker 2>vote component. It's got like two buttons like and dislike.

68
00:02:56.360 --> 00:02:59.400
<v Speaker 2>Instead of testing each button separately, it shows how to

69
00:02:59.439 --> 00:03:01.120
<v Speaker 2>test the whole component together.

70
00:03:01.479 --> 00:03:05.080
<v Speaker 1>So like simulating a user clicking on like then dislike

71
00:03:05.560 --> 00:03:07.360
<v Speaker 1>and making sure the counts update right.

72
00:03:07.520 --> 00:03:10.680
<v Speaker 2>Right, You're testing the entire voting system from a user's perspective,

73
00:03:10.759 --> 00:03:12.240
<v Speaker 2>making sure it all flows smoothly.

74
00:03:12.520 --> 00:03:16.560
<v Speaker 1>Makes sense, But doesn't that make integration tests way more complex.

75
00:03:16.800 --> 00:03:19.360
<v Speaker 2>It can be. You might have to you know, mock

76
00:03:19.439 --> 00:03:23.000
<v Speaker 2>some dependencies or fake some external services, but in the

77
00:03:23.120 --> 00:03:25.280
<v Speaker 2>end you get a way better understanding of how your

78
00:03:25.280 --> 00:03:26.400
<v Speaker 2>app actually behaves.

79
00:03:26.599 --> 00:03:29.800
<v Speaker 1>So it's about finding the right balance between complexity and

80
00:03:29.840 --> 00:03:30.759
<v Speaker 1>getting a full picture.

81
00:03:31.000 --> 00:03:34.080
<v Speaker 2>Yep, And the right approach depends on what you're testing.

82
00:03:34.479 --> 00:03:37.879
<v Speaker 2>Sometimes testing in isolation is all you need, like if

83
00:03:37.919 --> 00:03:39.800
<v Speaker 2>it's just a simple button or something, But for.

84
00:03:39.800 --> 00:03:42.840
<v Speaker 1>A feature with lots of moving parts, integration testing is

85
00:03:42.840 --> 00:03:43.879
<v Speaker 1>the way to go totally.

86
00:03:44.080 --> 00:03:47.280
<v Speaker 2>And oh, don't forget about legacy code. A lot of

87
00:03:47.280 --> 00:03:51.599
<v Speaker 2>projects have old tests written with tools like enzyme. Switching

88
00:03:51.599 --> 00:03:54.719
<v Speaker 2>these to RTL can seem tough, but it's so worth it.

89
00:03:54.879 --> 00:03:57.479
<v Speaker 1>Kind of like restoring a classic car. You want to

90
00:03:57.520 --> 00:03:59.520
<v Speaker 1>keep its charm, but give it a modern engine.

91
00:03:59.599 --> 00:04:03.039
<v Speaker 2>Exactly. By moving to RTL, you bring all these advantages

92
00:04:03.120 --> 00:04:06.159
<v Speaker 2>of modern testing to your older projects, making your tests

93
00:04:06.159 --> 00:04:09.639
<v Speaker 2>way better, easier to maintain, and in line with like

94
00:04:10.039 --> 00:04:11.400
<v Speaker 2>the best practices today.

95
00:04:11.680 --> 00:04:16.279
<v Speaker 1>Okay, so we've talked philosophy, the basics, even touched on

96
00:04:16.360 --> 00:04:19.879
<v Speaker 1>legacy code, but there's more right. RTL has this whole

97
00:04:20.199 --> 00:04:22.040
<v Speaker 1>ecosystem of advanced tools too.

98
00:04:22.240 --> 00:04:27.680
<v Speaker 2>Oh, yeah, we're just getting started es lint, plugins, testing, playground, WALLABYJS,

99
00:04:27.800 --> 00:04:29.720
<v Speaker 2>things that'll seriously level up your testing.

100
00:04:29.759 --> 00:04:32.079
<v Speaker 1>Well, the dive into those later those sounds super interesting.

101
00:04:32.319 --> 00:04:35.360
<v Speaker 1>I'm especially curious about this time traveling debugging thing you

102
00:04:35.360 --> 00:04:35.959
<v Speaker 1>mentioned before.

103
00:04:36.040 --> 00:04:38.639
<v Speaker 2>Ahah. Yeah, we'll get to that. And then there's Cypress,

104
00:04:38.680 --> 00:04:41.639
<v Speaker 2>which takes UI testing to like a whole other level,

105
00:04:41.680 --> 00:04:44.720
<v Speaker 2>letting you simulate complete user journeys throughout your application.

106
00:04:44.839 --> 00:04:46.920
<v Speaker 1>So Cypress is basically like a robot user that can

107
00:04:47.000 --> 00:04:49.439
<v Speaker 1>browse your entire website, add stuff to a cart, check

108
00:04:49.480 --> 00:04:50.160
<v Speaker 1>out all.

109
00:04:50.000 --> 00:04:53.120
<v Speaker 2>That exactly, and it integrates seamlessly with RTL, so you

110
00:04:53.160 --> 00:04:55.519
<v Speaker 2>get that user centric approach even for those end to

111
00:04:55.600 --> 00:04:58.959
<v Speaker 2>end tests. And it even uses design patterns like page

112
00:04:58.959 --> 00:05:01.600
<v Speaker 2>objects to help or organize and maintain your Cyprus test,

113
00:05:01.680 --> 00:05:04.000
<v Speaker 2>which is super helpful for larger projects.

114
00:05:04.199 --> 00:05:07.000
<v Speaker 1>All right, I'm definitely feeling the excitement building. We barely

115
00:05:07.000 --> 00:05:10.279
<v Speaker 1>scratch the surface, but I can already see how RTL

116
00:05:10.360 --> 00:05:12.879
<v Speaker 1>can completely transform testing for sure.

117
00:05:12.920 --> 00:05:15.519
<v Speaker 2>This is just the beginning. In the next part, we'll

118
00:05:15.519 --> 00:05:18.720
<v Speaker 2>get more into the practical applications of RTL, looking at

119
00:05:18.759 --> 00:05:23.120
<v Speaker 2>examples and strategies for testing different things. Stay tuned, all.

120
00:05:23.160 --> 00:05:26.199
<v Speaker 1>Right, Welcome back to our React testing library deep dive.

121
00:05:26.959 --> 00:05:30.240
<v Speaker 1>We're learning to think like users, not just code monkeys.

122
00:05:30.319 --> 00:05:33.399
<v Speaker 2>Ah huh, right, and this time we're going to get practical,

123
00:05:33.399 --> 00:05:36.839
<v Speaker 2>see how this whole user centric testing thing actually works

124
00:05:36.959 --> 00:05:39.240
<v Speaker 2>in you know, real projects.

125
00:05:39.399 --> 00:05:41.759
<v Speaker 1>Sounds good to me. Ready to get into the code.

126
00:05:41.839 --> 00:05:43.920
<v Speaker 2>Well, before we do that, let's just quickly revisit the

127
00:05:43.959 --> 00:05:48.560
<v Speaker 2>whole RTL philosophy. The book really hammers this point test

128
00:05:48.639 --> 00:05:51.279
<v Speaker 2>from the user's perspective. That's how you get tests that

129
00:05:51.319 --> 00:05:52.399
<v Speaker 2>are actually valuable.

130
00:05:52.600 --> 00:05:54.560
<v Speaker 1>Makes sense. At the end of the day, it's users

131
00:05:54.560 --> 00:05:56.079
<v Speaker 1>who are going to be using our app, so the

132
00:05:56.120 --> 00:05:57.439
<v Speaker 1>tests should reflect.

133
00:05:57.040 --> 00:06:00.480
<v Speaker 2>That right totally. We focus on the results users, not

134
00:06:00.519 --> 00:06:01.920
<v Speaker 2>just the internal code stuff.

135
00:06:02.160 --> 00:06:05.199
<v Speaker 1>Okay, so what does that look like in practice? Can

136
00:06:05.240 --> 00:06:06.240
<v Speaker 1>you give me an example?

137
00:06:06.560 --> 00:06:10.160
<v Speaker 2>Sure, Imagine we're building an online store and we're testing

138
00:06:10.199 --> 00:06:11.199
<v Speaker 2>that ad to cart.

139
00:06:11.079 --> 00:06:15.240
<v Speaker 1>Button, classic e commerce feature. Gotta have that exactly now.

140
00:06:15.279 --> 00:06:18.040
<v Speaker 2>The old way of testing might just be like making

141
00:06:18.040 --> 00:06:20.040
<v Speaker 2>sure the ad to kurt function gets called when you

142
00:06:20.079 --> 00:06:21.399
<v Speaker 2>click it right, checking.

143
00:06:21.120 --> 00:06:22.680
<v Speaker 1>The code behind it is doing its thing.

144
00:06:22.800 --> 00:06:25.519
<v Speaker 2>But with RTL it's different. We don't care as much

145
00:06:25.519 --> 00:06:27.800
<v Speaker 2>about that function call. We care about what the user

146
00:06:27.839 --> 00:06:29.920
<v Speaker 2>actually sees happening.

147
00:06:29.519 --> 00:06:31.600
<v Speaker 1>So we check that the item actually shows up in

148
00:06:31.639 --> 00:06:32.680
<v Speaker 1>their cart after.

149
00:06:32.439 --> 00:06:35.920
<v Speaker 2>They click yep, and that the cart counter updates, maybe

150
00:06:36.000 --> 00:06:38.279
<v Speaker 2>even a success message pops up. Stuff like that.

151
00:06:38.639 --> 00:06:41.920
<v Speaker 1>So it's not just does the button work, it's does

152
00:06:41.959 --> 00:06:45.639
<v Speaker 1>the whole adding to card experience work correctly? Right?

153
00:06:45.879 --> 00:06:48.959
<v Speaker 2>And these tests are way more resistant to code changes, Like,

154
00:06:49.079 --> 00:06:51.079
<v Speaker 2>as long as what the user sees is the same,

155
00:06:51.720 --> 00:06:54.839
<v Speaker 2>your tests should pass even if you totally rewrite the

156
00:06:54.879 --> 00:06:55.560
<v Speaker 2>code underneath.

157
00:06:55.800 --> 00:06:59.959
<v Speaker 1>That's smart future proof testing. Speaking of which, the book

158
00:07:00.040 --> 00:07:03.519
<v Speaker 1>also talked about integration testing versus isolation testing. Can you

159
00:07:03.560 --> 00:07:04.360
<v Speaker 1>break that down for me?

160
00:07:04.680 --> 00:07:08.240
<v Speaker 2>Sure? Integration testing is like seeing how all the different

161
00:07:08.279 --> 00:07:11.279
<v Speaker 2>parts of your app work together, like a well oiled machine,

162
00:07:11.399 --> 00:07:12.079
<v Speaker 2>like putting.

163
00:07:11.800 --> 00:07:14.879
<v Speaker 1>The puzzle pieces together, making sure they all fit exactly.

164
00:07:15.480 --> 00:07:18.199
<v Speaker 2>The book has a great example a vote component. It's

165
00:07:18.240 --> 00:07:21.800
<v Speaker 2>got two buttons like and dislike. Instead of testing each

166
00:07:21.839 --> 00:07:23.680
<v Speaker 2>button on its own, it shows how to test the

167
00:07:23.720 --> 00:07:25.680
<v Speaker 2>whole component as one unit.

168
00:07:26.040 --> 00:07:29.639
<v Speaker 1>So we'd be simulating a user clicking like than dislike

169
00:07:30.199 --> 00:07:32.040
<v Speaker 1>and making sure the counts are right yep.

170
00:07:32.360 --> 00:07:35.199
<v Speaker 2>You're testing the whole voting mechanism from the user's point

171
00:07:35.199 --> 00:07:38.000
<v Speaker 2>of view, ensuring that all the pieces work well together.

172
00:07:38.279 --> 00:07:41.480
<v Speaker 1>That makes sense, But doesn't that make integration tests like

173
00:07:41.879 --> 00:07:43.680
<v Speaker 1>more complicated to set up?

174
00:07:43.879 --> 00:07:46.839
<v Speaker 2>Yeah, sometimes you might need to mock certain things or

175
00:07:46.879 --> 00:07:50.199
<v Speaker 2>simulate external services things like that, but you get a

176
00:07:50.319 --> 00:07:53.199
<v Speaker 2>much better understanding of how the whole app behaves.

177
00:07:53.240 --> 00:07:56.040
<v Speaker 1>So it's a trade off. More complex to set up,

178
00:07:56.079 --> 00:07:58.399
<v Speaker 1>but you get a more complete picture exactly.

179
00:07:58.600 --> 00:08:01.879
<v Speaker 2>And that's why choosing the right testing strategy is so important.

180
00:08:02.199 --> 00:08:05.560
<v Speaker 2>Sometimes isolation testing is enough, like if you're just working

181
00:08:05.639 --> 00:08:07.680
<v Speaker 2>on a button or something small, but if it's.

182
00:08:07.600 --> 00:08:11.040
<v Speaker 1>A big feature with lots of components interacting, integration testing

183
00:08:11.079 --> 00:08:12.560
<v Speaker 1>is probably better, right.

184
00:08:12.959 --> 00:08:16.319
<v Speaker 2>And speaking of complex features, things can get even trickier

185
00:08:16.399 --> 00:08:19.560
<v Speaker 2>when you're using libraries like reducts, which is often used

186
00:08:19.560 --> 00:08:21.480
<v Speaker 2>for managing State and React apps.

187
00:08:21.560 --> 00:08:24.959
<v Speaker 1>Oh yeah, reducs. I've definitely struggled with testing those components.

188
00:08:25.000 --> 00:08:27.560
<v Speaker 1>It's like trying to test an engine while it's still

189
00:08:27.560 --> 00:08:28.399
<v Speaker 1>attached to the car.

190
00:08:28.600 --> 00:08:31.920
<v Speaker 2>Perfect analogy. You need a way to isolate the component

191
00:08:31.959 --> 00:08:34.799
<v Speaker 2>you're testing from all that extra stuff. That's where custom

192
00:08:34.840 --> 00:08:37.519
<v Speaker 2>render methods come in. They let us create a controlled

193
00:08:37.600 --> 00:08:39.600
<v Speaker 2>environment for testing Redux components.

194
00:08:39.720 --> 00:08:42.240
<v Speaker 1>So instead of using the real reduct store, we can

195
00:08:42.279 --> 00:08:46.120
<v Speaker 1>create a fake one with like preset data makes things

196
00:08:46.159 --> 00:08:47.799
<v Speaker 1>more predictable exactly.

197
00:08:48.320 --> 00:08:50.639
<v Speaker 2>And this approach can be used with other libraries too.

198
00:08:50.799 --> 00:08:53.399
<v Speaker 2>It's all about isolating what you're testing, right.

199
00:08:53.440 --> 00:08:55.639
<v Speaker 1>I see in the book also had some good tips

200
00:08:55.639 --> 00:08:58.519
<v Speaker 1>for dealing with legacy code. Right. A lot of projects

201
00:08:58.519 --> 00:09:02.240
<v Speaker 1>have those older tests using things like enzyme and moving

202
00:09:02.240 --> 00:09:03.799
<v Speaker 1>those to RTL seems daunting.

203
00:09:04.080 --> 00:09:06.720
<v Speaker 2>It can be, but the book offers some great guidance.

204
00:09:07.000 --> 00:09:10.000
<v Speaker 2>Think of it like renovating a classic car. You want

205
00:09:10.000 --> 00:09:13.159
<v Speaker 2>to keep the charm, but update it with modern stuff.

206
00:09:13.240 --> 00:09:15.519
<v Speaker 1>So we're not just throwing away all the old tests,

207
00:09:15.960 --> 00:09:18.720
<v Speaker 1>We're updating them to use RTL's approach.

208
00:09:18.600 --> 00:09:21.480
<v Speaker 2>Exactly, and that way you get all the benefits of

209
00:09:21.600 --> 00:09:25.080
<v Speaker 2>RTL even in older projects. Makes your tests more robust,

210
00:09:25.399 --> 00:09:28.200
<v Speaker 2>easier to work with, and align with current best practices.

211
00:09:28.320 --> 00:09:31.200
<v Speaker 1>Okay, that makes sense. Now I'm really curious about those

212
00:09:31.200 --> 00:09:33.759
<v Speaker 1>advanced tools you mentioned earlier. Can we get into those now?

213
00:09:33.919 --> 00:09:37.039
<v Speaker 2>Sure. One of the essentials is es LNT. It's like

214
00:09:37.080 --> 00:09:40.159
<v Speaker 2>a codelinter, but it can be extended with plugins specifically

215
00:09:40.159 --> 00:09:41.200
<v Speaker 2>for RTL.

216
00:09:40.879 --> 00:09:43.720
<v Speaker 1>And JEST, So ESLINT for those who don't know, it's

217
00:09:43.759 --> 00:09:46.320
<v Speaker 1>like a grammar checker for your code helps you catch

218
00:09:46.440 --> 00:09:47.960
<v Speaker 1>errors and write cleaner.

219
00:09:47.559 --> 00:09:50.519
<v Speaker 2>Code exactly, And these plug ins for RTL and JEST

220
00:09:50.600 --> 00:09:53.600
<v Speaker 2>they take it further, giving you rules and tips specifically

221
00:09:53.600 --> 00:09:56.279
<v Speaker 2>for writing good tests. They can help you avoid common

222
00:09:56.320 --> 00:09:58.440
<v Speaker 2>mistakes and generally make your test better.

223
00:09:58.799 --> 00:10:01.440
<v Speaker 1>So like having a testing expert looking over your shoulder

224
00:10:01.759 --> 00:10:03.600
<v Speaker 1>giving you advice as you write code.

225
00:10:03.759 --> 00:10:07.200
<v Speaker 2>Ah yeah. And then there's Testing Playground. If es lint

226
00:10:07.240 --> 00:10:10.000
<v Speaker 2>is the grammar checker, this is like the visual dictionary

227
00:10:10.039 --> 00:10:12.440
<v Speaker 2>for your tests. You can test out different selectors and

228
00:10:12.440 --> 00:10:14.000
<v Speaker 2>see how they work with your HTML.

229
00:10:14.120 --> 00:10:17.120
<v Speaker 1>I love Testing Playground. It's like having X ray vision

230
00:10:17.120 --> 00:10:20.480
<v Speaker 1>for your components, showing you exactly what elements you need

231
00:10:20.519 --> 00:10:21.639
<v Speaker 1>to target in your tests.

232
00:10:21.840 --> 00:10:25.360
<v Speaker 2>Right, no more guessing about which selectors to use. It

233
00:10:25.399 --> 00:10:27.919
<v Speaker 2>helps you write tests that are more accurate and less

234
00:10:27.960 --> 00:10:30.679
<v Speaker 2>likely to break when your code changes. And for folks

235
00:10:30.679 --> 00:10:34.120
<v Speaker 2>who want instant feedback and some really cool debugging features,

236
00:10:34.440 --> 00:10:36.120
<v Speaker 2>there's Wallaby dot js.

237
00:10:36.279 --> 00:10:39.320
<v Speaker 1>Okay, Wallaby dot js. Now things are getting interesting. What's

238
00:10:39.320 --> 00:10:40.240
<v Speaker 1>so special about it?

239
00:10:40.519 --> 00:10:42.679
<v Speaker 2>Well, it's a paid tool, but it's worth it. It

240
00:10:42.720 --> 00:10:45.440
<v Speaker 2>integrates right into your code editor and gives you real

241
00:10:45.480 --> 00:10:48.759
<v Speaker 2>time feedback as you're writing tests. You see errors immediately

242
00:10:49.000 --> 00:10:51.120
<v Speaker 2>you can step through your code and see what's happening.

243
00:10:51.200 --> 00:10:53.360
<v Speaker 1>Time travel do bugging. That's the thing you mentioned.

244
00:10:53.159 --> 00:10:57.639
<v Speaker 2>Earlier, right, Yep, it's super helpful for finding those tricky bugs.

245
00:10:58.120 --> 00:11:01.799
<v Speaker 2>Wallaby can really speed up you're testing and debugging process.

246
00:11:02.200 --> 00:11:04.759
<v Speaker 1>So it's like having a personal testing assistant right there

247
00:11:04.759 --> 00:11:08.039
<v Speaker 1>in your code. Awesome. What about Cypress you mentioned that

248
00:11:08.039 --> 00:11:08.600
<v Speaker 1>earlier too.

249
00:11:08.720 --> 00:11:11.159
<v Speaker 2>Yeah, Cypress is a whole other level. It's for end

250
00:11:11.159 --> 00:11:14.679
<v Speaker 2>to end UI testing. Imagine a robot user that can

251
00:11:14.720 --> 00:11:18.120
<v Speaker 2>actually interact with your app, like browsing through pages, clicking

252
00:11:18.120 --> 00:11:19.480
<v Speaker 2>on things, filling out forms.

253
00:11:19.480 --> 00:11:23.600
<v Speaker 1>So Cypress is like testing the entire user journey from start.

254
00:11:23.399 --> 00:11:27.320
<v Speaker 2>To finish exactly. It's especially powerful for testing complex workflows

255
00:11:27.320 --> 00:11:30.240
<v Speaker 2>and making sure your app behaves correctly in like real

256
00:11:30.279 --> 00:11:34.799
<v Speaker 2>world scenarios. And the best part is it integrates seamlessly with.

257
00:11:34.919 --> 00:11:37.720
<v Speaker 1>RTL, so you get that user centric approach even for

258
00:11:37.759 --> 00:11:39.240
<v Speaker 1>those big end to end tests.

259
00:11:39.519 --> 00:11:42.799
<v Speaker 2>Right. And Cypress has these things called page objects, which

260
00:11:42.840 --> 00:11:45.480
<v Speaker 2>are like blueprints for different parts of your app. They

261
00:11:45.519 --> 00:11:48.159
<v Speaker 2>make it way easier to organize and maintain your tests,

262
00:11:48.480 --> 00:11:49.919
<v Speaker 2>especially for large projects.

263
00:11:49.960 --> 00:11:52.679
<v Speaker 1>So Cypress is like the ultimate test pilot, putting your

264
00:11:52.679 --> 00:11:55.120
<v Speaker 1>app through as paces and making sure it can handle

265
00:11:55.200 --> 00:11:56.519
<v Speaker 1>anything users throw at it.

266
00:11:56.679 --> 00:11:59.600
<v Speaker 2>Ah exactly, and Cypress can do more than just simulate

267
00:11:59.639 --> 00:12:03.240
<v Speaker 2>user apps. You can test APIs directly from your UI, tests,

268
00:12:03.559 --> 00:12:07.480
<v Speaker 2>check network requests, even interact with databases. It's really powerful.

269
00:12:07.799 --> 00:12:10.720
<v Speaker 1>Okay, so the Cypress can basically test every layer of

270
00:12:10.759 --> 00:12:14.600
<v Speaker 1>your application. Pretty impressive. What about those design patterns you

271
00:12:14.639 --> 00:12:17.519
<v Speaker 1>mentioned for writing better subriss tests.

272
00:12:17.440 --> 00:12:20.320
<v Speaker 2>Right, One of the most useful is the page object

273
00:12:20.360 --> 00:12:22.200
<v Speaker 2>model or pom POM.

274
00:12:22.480 --> 00:12:26.080
<v Speaker 1>That's about making tests more organized and less likely to break. Right.

275
00:12:26.399 --> 00:12:28.639
<v Speaker 2>The idea is to create separate pieces of code that

276
00:12:28.679 --> 00:12:32.039
<v Speaker 2>represent different pages or sections of your app. Each page

277
00:12:32.080 --> 00:12:35.399
<v Speaker 2>object like encapsulates all the logic for interacting with that

278
00:12:35.480 --> 00:12:36.799
<v Speaker 2>specific part of the UI.

279
00:12:36.960 --> 00:12:39.600
<v Speaker 1>So instead of having all your Cypress commands scattered throughout

280
00:12:39.600 --> 00:12:42.200
<v Speaker 1>your tests, you group them logically within these page objects.

281
00:12:42.519 --> 00:12:43.879
<v Speaker 1>Makes things way cleaner.

282
00:12:43.840 --> 00:12:47.000
<v Speaker 2>Exactly, and it makes your tests less sensitive to changes

283
00:12:47.039 --> 00:12:50.000
<v Speaker 2>in your HTML. If the layout changes, you just update

284
00:12:50.039 --> 00:12:52.240
<v Speaker 2>the page object, not a bunch of different tests.

285
00:12:52.360 --> 00:12:54.919
<v Speaker 1>Saves a ton of time, less fixing tests, more time

286
00:12:54.960 --> 00:12:58.679
<v Speaker 1>for new features. What about those custom Cypress commands you mentioned, Oh,

287
00:12:58.720 --> 00:12:59.360
<v Speaker 1>those are great.

288
00:12:59.559 --> 00:13:02.440
<v Speaker 2>They let you if you extend Cypress's functionality and create

289
00:13:02.519 --> 00:13:05.600
<v Speaker 2>reusable pieces of code for your tests. Think about a

290
00:13:05.600 --> 00:13:09.120
<v Speaker 2>common task like logging in or creating a new user.

291
00:13:08.879 --> 00:13:10.480
<v Speaker 1>Stuff we do all the time and testing.

292
00:13:10.799 --> 00:13:13.039
<v Speaker 2>Instead of writing the same Cypress commands over and over,

293
00:13:13.120 --> 00:13:15.519
<v Speaker 2>you can create a custom command that does that whole

294
00:13:15.559 --> 00:13:16.200
<v Speaker 2>thing for you.

295
00:13:16.279 --> 00:13:18.679
<v Speaker 1>So it's like creating your own little library of testing

296
00:13:18.720 --> 00:13:19.879
<v Speaker 1>actions exactly.

297
00:13:20.279 --> 00:13:24.200
<v Speaker 2>Makes your tests shorter, easier to read, and less prone

298
00:13:24.200 --> 00:13:27.919
<v Speaker 2>to errors. And Cypress can even test APIs directly from

299
00:13:27.960 --> 00:13:30.440
<v Speaker 2>your UI tests. You can make sure your front end

300
00:13:30.480 --> 00:13:33.120
<v Speaker 2>and back end are talking to each other properly without

301
00:13:33.159 --> 00:13:34.240
<v Speaker 2>writing separate tests.

302
00:13:34.480 --> 00:13:36.799
<v Speaker 1>Wow, so I can test my UI and API in

303
00:13:36.840 --> 00:13:40.399
<v Speaker 1>the same Cypress test suite. That's amazing. Saves so much

304
00:13:40.440 --> 00:13:41.159
<v Speaker 1>time and effort.

305
00:13:41.360 --> 00:13:44.679
<v Speaker 2>Right and by testing your API from the user's perspective,

306
00:13:44.840 --> 00:13:48.559
<v Speaker 2>you're simulating real world usage more accurately. You can verify

307
00:13:48.600 --> 00:13:51.600
<v Speaker 2>that data is flowing correctly and your app is responding

308
00:13:51.679 --> 00:13:52.279
<v Speaker 2>as it should.

309
00:13:52.559 --> 00:13:55.559
<v Speaker 1>So Cypress really is like the ultimate testing tool, can

310
00:13:55.559 --> 00:13:57.039
<v Speaker 1>handle anything you throw at it.

311
00:13:57.039 --> 00:14:00.320
<v Speaker 2>It's really powerful. Now let's talk about something that can

312
00:14:00.320 --> 00:14:03.200
<v Speaker 2>be really helpful when you're working with like non technical

313
00:14:03.240 --> 00:14:07.320
<v Speaker 2>folks writing tests in a way that anyone can understand.

314
00:14:07.639 --> 00:14:09.799
<v Speaker 1>Okay, interesting, how do we do that?

315
00:14:10.159 --> 00:14:13.279
<v Speaker 2>Well? Cypress works great with something called Cucumber, which uses

316
00:14:13.320 --> 00:14:17.360
<v Speaker 2>this language called Girkin. It's a simple, plain English way

317
00:14:17.440 --> 00:14:21.840
<v Speaker 2>to write tests. Uses keywords like given, when.

318
00:14:21.879 --> 00:14:24.600
<v Speaker 1>And then, so it's like writing out the steps of

319
00:14:24.639 --> 00:14:27.279
<v Speaker 1>a test as if you were explaining it to someone.

320
00:14:27.399 --> 00:14:30.519
<v Speaker 1>Makes it clear what's being tested and what should happen exactly.

321
00:14:30.600 --> 00:14:34.159
<v Speaker 2>It bridges the gap between developers and everyone else. Cypers

322
00:14:34.159 --> 00:14:36.720
<v Speaker 2>can run these Gurkin tests automatically, so everyone's on the

323
00:14:36.720 --> 00:14:39.799
<v Speaker 2>same page about what's being tested and what success looks like.

324
00:14:39.960 --> 00:14:42.480
<v Speaker 1>That's awesome. A shared language for testing. I like that.

325
00:14:42.960 --> 00:14:44.919
<v Speaker 1>So we've got Cypress for end to end testing. But

326
00:14:44.960 --> 00:14:48.919
<v Speaker 1>what about testing those less than ideal situations, like when

327
00:14:48.960 --> 00:14:51.240
<v Speaker 1>things go wrong? How do we make sure our app

328
00:14:51.279 --> 00:14:52.440
<v Speaker 1>handles those gracefully?

329
00:14:52.759 --> 00:14:56.559
<v Speaker 2>Ah, you're talking about edge cases, those tricky little bugs

330
00:14:56.559 --> 00:14:59.399
<v Speaker 2>that pop up when you least expect them, and that's

331
00:14:59.399 --> 00:15:02.799
<v Speaker 2>where error handling and boundary testing come in. The book

332
00:15:02.799 --> 00:15:05.919
<v Speaker 2>has some great advice on using RTL for those situations,

333
00:15:06.000 --> 00:15:09.759
<v Speaker 2>making sure your app stays stable and user friendly even

334
00:15:09.759 --> 00:15:10.919
<v Speaker 2>when things go sideways.

335
00:15:11.200 --> 00:15:12.720
<v Speaker 1>So how do we do that with RTL?

336
00:15:13.039 --> 00:15:16.399
<v Speaker 2>One way? Is to use RTL's fire event method, you

337
00:15:16.440 --> 00:15:19.200
<v Speaker 2>can simulate all sorts of events that might trigger errors

338
00:15:19.679 --> 00:15:24.159
<v Speaker 2>like invalid input, network problems, unexpected data from an API.

339
00:15:24.399 --> 00:15:26.840
<v Speaker 1>So we're basically trying to break our app on purpose

340
00:15:27.000 --> 00:15:29.279
<v Speaker 1>in a safe environment to see how it reacts.

341
00:15:29.360 --> 00:15:32.720
<v Speaker 2>Uh huh yeah, pretty much. And then using RTL's querying methods,

342
00:15:32.720 --> 00:15:35.000
<v Speaker 2>we can check that the right error messages are shown

343
00:15:35.240 --> 00:15:37.200
<v Speaker 2>or that the app re covers properly.

344
00:15:36.960 --> 00:15:40.080
<v Speaker 1>So instead of crashing, the app can handle errors gracefully

345
00:15:40.399 --> 00:15:41.919
<v Speaker 1>and guide the user back on track.

346
00:15:42.080 --> 00:15:45.120
<v Speaker 2>Exactly. It's about making the user experience as robust and

347
00:15:45.200 --> 00:15:47.720
<v Speaker 2>resilient as possible, and the book gives some really good

348
00:15:47.720 --> 00:15:49.440
<v Speaker 2>examples of how to do that with URTL.

349
00:15:49.639 --> 00:15:51.960
<v Speaker 1>I like that thinking like a user, but also thinking

350
00:15:52.000 --> 00:15:54.519
<v Speaker 1>like a user who might make mistakes or run into problems.

351
00:15:54.879 --> 00:15:58.960
<v Speaker 2>Exactly. It's all part of building a truly user centric application.

352
00:16:00.000 --> 00:16:01.879
<v Speaker 2>Well have you ever had to make changes to your

353
00:16:01.919 --> 00:16:05.039
<v Speaker 2>app but you were worried about accidentally breaking something else

354
00:16:05.080 --> 00:16:05.759
<v Speaker 2>in the process.

355
00:16:05.919 --> 00:16:10.320
<v Speaker 1>Oh yeah, regressions every developer's worst nightmare. You fix one

356
00:16:10.360 --> 00:16:11.799
<v Speaker 1>thing and break two other things.

357
00:16:11.919 --> 00:16:15.480
<v Speaker 2>Uh huh yep. That's where regression testing comes in, and

358
00:16:15.679 --> 00:16:18.840
<v Speaker 2>RTL has us covered there too. How So RTL gives

359
00:16:18.840 --> 00:16:20.759
<v Speaker 2>you the tools to write tests that cover all the

360
00:16:20.799 --> 00:16:23.600
<v Speaker 2>important parts of your app. With a good set of tests,

361
00:16:23.679 --> 00:16:26.759
<v Speaker 2>you can make changes confidently knowing that your tests will

362
00:16:26.759 --> 00:16:28.919
<v Speaker 2>catch any regressions before they go live.

363
00:16:29.039 --> 00:16:30.840
<v Speaker 1>So it's like having a safety net making sure you

364
00:16:30.840 --> 00:16:33.759
<v Speaker 1>don't accidentally introduce new bugs when you're fixing old ones.

365
00:16:33.919 --> 00:16:36.279
<v Speaker 2>Exactly. And the book even shows you how to refactor

366
00:16:36.399 --> 00:16:38.799
<v Speaker 2>old tests written with enzyme so you can bring those

367
00:16:38.879 --> 00:16:40.639
<v Speaker 2>up to speed with RTL's approach.

368
00:16:40.840 --> 00:16:44.000
<v Speaker 1>Awesome. So RTL is great for catching regressions in general.

369
00:16:44.320 --> 00:16:46.600
<v Speaker 1>But the book also had a specific example about a

370
00:16:46.639 --> 00:16:49.799
<v Speaker 1>budget app, right, something that helps users track their spending.

371
00:16:49.960 --> 00:16:52.639
<v Speaker 2>Yeah, it shows how to write integration tests for that app,

372
00:16:52.759 --> 00:16:55.519
<v Speaker 2>verifying that all the components work together correctly.

373
00:16:55.799 --> 00:16:58.440
<v Speaker 1>So we're testing the whole budget management flow, not just

374
00:16:58.519 --> 00:16:59.360
<v Speaker 1>individual pieces.

375
00:17:00.000 --> 00:17:03.240
<v Speaker 2>Make sense, right, And to show regression testing in action,

376
00:17:03.759 --> 00:17:07.119
<v Speaker 2>the book goes through updating the material UI library that

377
00:17:07.160 --> 00:17:10.839
<v Speaker 2>the app uses. That's something that can often introduce regressions

378
00:17:11.000 --> 00:17:12.000
<v Speaker 2>if you're not careful.

379
00:17:12.119 --> 00:17:15.039
<v Speaker 1>Oh, I've been there, updating a library and suddenly half

380
00:17:15.039 --> 00:17:15.839
<v Speaker 1>your app is broken.

381
00:17:15.960 --> 00:17:18.359
<v Speaker 2>By having a good set of tests like the ones

382
00:17:18.400 --> 00:17:21.359
<v Speaker 2>shown in the book, you can catch those regressions early

383
00:17:21.799 --> 00:17:23.720
<v Speaker 2>and fix them before they affect your users.

384
00:17:23.839 --> 00:17:28.319
<v Speaker 1>That's so important. So URTL helps us catch regressions, refacture

385
00:17:28.359 --> 00:17:32.640
<v Speaker 1>old tests, and even test complex workflows. Is there anything

386
00:17:32.680 --> 00:17:33.240
<v Speaker 1>it can't do?

387
00:17:33.480 --> 00:17:36.440
<v Speaker 2>Uh huh. Well, it's not magic, but it's pretty close.

388
00:17:36.759 --> 00:17:40.400
<v Speaker 2>It definitely makes testing way easier and more effective for sure.

389
00:17:40.599 --> 00:17:43.440
<v Speaker 1>And the book also talks about best practices for writing

390
00:17:43.519 --> 00:17:45.960
<v Speaker 1>tests right, things like how to name them, how to

391
00:17:46.079 --> 00:17:46.720
<v Speaker 1>organize them.

392
00:17:46.839 --> 00:17:50.039
<v Speaker 2>Yep, no one wants to deal with a messy, confusing

393
00:17:50.119 --> 00:17:52.240
<v Speaker 2>test suite. It's like trying to find a needle in

394
00:17:52.240 --> 00:17:52.839
<v Speaker 2>a haystack.

395
00:17:53.279 --> 00:17:55.640
<v Speaker 1>Right. So it's not just about writing tests, it's about

396
00:17:55.680 --> 00:17:59.119
<v Speaker 1>writing tests that are easy to understand and maintain exactly.

397
00:17:59.440 --> 00:18:02.200
<v Speaker 2>We should tests with the same care we treat our

398
00:18:02.200 --> 00:18:05.799
<v Speaker 2>production code. Now there's one more challenge. I want to

399
00:18:05.799 --> 00:18:09.440
<v Speaker 2>mention something. A lot of developers struggle with choosing the

400
00:18:09.519 --> 00:18:13.559
<v Speaker 2>right query selectors to target specific elements in their components.

401
00:18:13.920 --> 00:18:18.000
<v Speaker 2>It can be a real pain, especially with complex HTML structures.

402
00:18:18.039 --> 00:18:20.519
<v Speaker 1>Oh tell me about it. I've spent way too much

403
00:18:20.519 --> 00:18:22.480
<v Speaker 1>time trying to figure out the perfect selector.

404
00:18:22.519 --> 00:18:26.960
<v Speaker 2>Well, thankfully, there's this awesome tool called testing Playground. It's interactive.

405
00:18:27.119 --> 00:18:30.480
<v Speaker 2>You can paste in your components HTML and visually see

406
00:18:30.480 --> 00:18:32.039
<v Speaker 2>how different selectors work.

407
00:18:32.079 --> 00:18:33.799
<v Speaker 1>Like a treasure map that leads you right to the

408
00:18:33.839 --> 00:18:34.720
<v Speaker 1>element you're looking for.

409
00:18:34.880 --> 00:18:37.119
<v Speaker 2>Uh huh, yeah, exactly. It takes all the guesswork out

410
00:18:37.119 --> 00:18:40.079
<v Speaker 2>of it, and Testing Playground doesn't just find any selector.

411
00:18:40.359 --> 00:18:43.759
<v Speaker 2>It tries to find the best one, following RTL's best practices.

412
00:18:44.119 --> 00:18:46.480
<v Speaker 1>So it's not just about finding a selector that works,

413
00:18:46.640 --> 00:18:48.240
<v Speaker 1>it's about finding the one that's going to be the

414
00:18:48.240 --> 00:18:51.039
<v Speaker 1>most robust and reliable in the long run. I love that.

415
00:18:51.200 --> 00:18:53.440
<v Speaker 2>Now, for those who really want to take their testing

416
00:18:53.440 --> 00:18:57.039
<v Speaker 2>workflow to the next level, there's Wallaby dot js gobytjs.

417
00:18:57.039 --> 00:18:59.680
<v Speaker 1>That's one with the time traveling debugging right. Yeah, yep.

418
00:19:00.160 --> 00:19:03.599
<v Speaker 2>It's a paid tool, but it's amazing. It integrates directly

419
00:19:03.599 --> 00:19:06.000
<v Speaker 2>into your code editor and gives you instant feedback as

420
00:19:06.000 --> 00:19:08.640
<v Speaker 2>you write tests. You see errors pop up right away.

421
00:19:08.720 --> 00:19:11.839
<v Speaker 2>You can step through your code execution and even rewind

422
00:19:11.880 --> 00:19:14.200
<v Speaker 2>time to see exactly when something went wrong.

423
00:19:14.400 --> 00:19:16.640
<v Speaker 1>That's incredible, like having a testing superpower.

424
00:19:16.759 --> 00:19:19.720
<v Speaker 2>Uh huh. It really does feel that way. Sometimes. It

425
00:19:19.759 --> 00:19:23.079
<v Speaker 2>can make writing and debugging tests so much faster and

426
00:19:23.160 --> 00:19:23.920
<v Speaker 2>more enjoyable.

427
00:19:24.240 --> 00:19:26.680
<v Speaker 1>So Wallaby dad js is definitely something to check out

428
00:19:26.880 --> 00:19:28.119
<v Speaker 1>if you're serious about testing.

429
00:19:28.279 --> 00:19:31.599
<v Speaker 2>Absolutely. Now, let's shift gears and talk about end to

430
00:19:31.720 --> 00:19:33.240
<v Speaker 2>end testing with Cypress.

431
00:19:33.759 --> 00:19:38.319
<v Speaker 1>Cypress, that's the framework that simulates real user interactions.

432
00:19:37.799 --> 00:19:42.079
<v Speaker 2>Right exactly. Imagine a robot user that can browse your website,

433
00:19:42.440 --> 00:19:45.440
<v Speaker 2>click buttons, fill out forms, and do everything a real

434
00:19:45.559 --> 00:19:46.240
<v Speaker 2>user would do.

435
00:19:46.359 --> 00:19:49.119
<v Speaker 1>So it's like testing the entire user journey from start

436
00:19:49.160 --> 00:19:49.960
<v Speaker 1>to finish.

437
00:19:49.759 --> 00:19:52.440
<v Speaker 2>Right, And Cypress makes it surprisingly easy to write these

438
00:19:52.519 --> 00:19:55.559
<v Speaker 2>kinds of tests and has a really nice visual test

439
00:19:55.599 --> 00:19:58.160
<v Speaker 2>runner that shows you exactly what's happening as your tests

440
00:19:58.160 --> 00:19:58.920
<v Speaker 2>are running, so you.

441
00:19:58.920 --> 00:20:01.559
<v Speaker 1>Can actually watch the about user interact with your app.

442
00:20:01.799 --> 00:20:02.480
<v Speaker 1>That's awesome.

443
00:20:02.839 --> 00:20:05.279
<v Speaker 2>Yeah, it's really cool and it's super helpful for finding

444
00:20:05.319 --> 00:20:08.480
<v Speaker 2>and fixing problems. But Cypress can do more than just

445
00:20:08.559 --> 00:20:12.599
<v Speaker 2>simulate user interactions. You can also use it to test APIs,

446
00:20:13.119 --> 00:20:17.000
<v Speaker 2>verify network requests, and even interact with databases. It's a

447
00:20:17.039 --> 00:20:19.160
<v Speaker 2>really comprehensive testing solution.

448
00:20:19.319 --> 00:20:20.599
<v Speaker 1>Sounds like Cypress has it all.

449
00:20:20.720 --> 00:20:23.720
<v Speaker 2>It's pretty amazing. But even with a tool as powerful

450
00:20:23.720 --> 00:20:26.000
<v Speaker 2>as Cypress, it's important to write your tests in a

451
00:20:26.039 --> 00:20:30.079
<v Speaker 2>way that's organized and easy to maintain. That's where design

452
00:20:30.160 --> 00:20:30.920
<v Speaker 2>patterns come in.

453
00:20:31.160 --> 00:20:33.880
<v Speaker 1>Design patterns those are like looprints for structuring your code

454
00:20:33.960 --> 00:20:35.039
<v Speaker 1>right exactly.

455
00:20:35.559 --> 00:20:38.400
<v Speaker 2>One of the most useful patterns for Cypress tests is

456
00:20:38.440 --> 00:20:41.240
<v Speaker 2>the page object model or POM for short.

457
00:20:41.400 --> 00:20:44.519
<v Speaker 1>POM that sound similiar. It's about making your tests less

458
00:20:44.599 --> 00:20:46.480
<v Speaker 1>likely to break when your code changes.

459
00:20:46.240 --> 00:20:49.000
<v Speaker 2>Right, you got it. The idea is to create separate

460
00:20:49.039 --> 00:20:52.920
<v Speaker 2>classes or modules that represent each page or section of

461
00:20:52.960 --> 00:20:55.960
<v Speaker 2>your app. These page objects contain all the logic for

462
00:20:56.000 --> 00:20:58.200
<v Speaker 2>interacting with that specific part of the UI.

463
00:20:58.400 --> 00:21:00.759
<v Speaker 1>Well. Instead of having your Cypress command and scattered all

464
00:21:00.799 --> 00:21:04.799
<v Speaker 1>over the place, you group them logically within these page objects.

465
00:21:04.440 --> 00:21:08.000
<v Speaker 2>Exactly, and by abstracting away the UI interactions, your tests

466
00:21:08.039 --> 00:21:11.079
<v Speaker 2>become less brittle. If the layout of a page changes,

467
00:21:11.160 --> 00:21:13.960
<v Speaker 2>you only need to update the page object, not a

468
00:21:14.000 --> 00:21:15.119
<v Speaker 2>ton of different tests.

469
00:21:15.519 --> 00:21:19.599
<v Speaker 1>Makes sense, less maintenance, more time for building new stuff right.

470
00:21:19.799 --> 00:21:23.319
<v Speaker 2>The book also mentions the power of using custom Cypress commands.

471
00:21:23.480 --> 00:21:24.880
<v Speaker 1>Custom commands what are those?

472
00:21:25.079 --> 00:21:28.279
<v Speaker 2>They let you create reusable chunks of code for common

473
00:21:28.319 --> 00:21:31.880
<v Speaker 2>actions in your tests. For example, imagine you have a

474
00:21:31.920 --> 00:21:34.680
<v Speaker 2>common workflow in your app, like logging in or creating

475
00:21:34.680 --> 00:21:35.000
<v Speaker 2>a new.

476
00:21:34.920 --> 00:21:37.880
<v Speaker 1>Account, stuff we do all the time in testing exactly.

477
00:21:38.440 --> 00:21:41.200
<v Speaker 2>Instead of writing those same Cypress commands over and over

478
00:21:41.240 --> 00:21:43.839
<v Speaker 2>in different tests, you can create a custom command that

479
00:21:43.920 --> 00:21:45.720
<v Speaker 2>encapsulates that entire workflow.

480
00:21:45.920 --> 00:21:48.519
<v Speaker 1>So it's like building your own library of testing actions.

481
00:21:48.640 --> 00:21:51.119
<v Speaker 1>Makes your test more concise and less repetitive.

482
00:21:51.279 --> 00:21:55.519
<v Speaker 2>Exactly, and less repetition means fewer errors and inconsistencies in

483
00:21:55.519 --> 00:21:56.039
<v Speaker 2>your tests.

484
00:21:56.119 --> 00:21:57.720
<v Speaker 1>I could see how that would be super helpful.

485
00:21:57.839 --> 00:22:00.839
<v Speaker 2>Cypress also lets you test your apid directly from your

486
00:22:00.960 --> 00:22:03.400
<v Speaker 2>UI tests, so you can make sure the front end

487
00:22:03.440 --> 00:22:05.960
<v Speaker 2>and back end are talking to each other correctly without

488
00:22:06.000 --> 00:22:07.440
<v Speaker 2>writing separate API tests.

489
00:22:07.759 --> 00:22:10.519
<v Speaker 1>Wow. So I can test both my UI and API

490
00:22:11.079 --> 00:22:14.319
<v Speaker 1>from the same Cypress test suite. That's pretty amazing. It

491
00:22:14.359 --> 00:22:15.440
<v Speaker 1>saves a ton of time.

492
00:22:15.400 --> 00:22:17.279
<v Speaker 2>It really does, and it's a more realistic way to

493
00:22:17.319 --> 00:22:19.400
<v Speaker 2>test because in the real world, your front end and

494
00:22:19.519 --> 00:22:21.160
<v Speaker 2>back end are always interacting.

495
00:22:21.680 --> 00:22:24.519
<v Speaker 1>Okay, I'm sold on Cypress. It sounds like an incredibly

496
00:22:24.559 --> 00:22:25.920
<v Speaker 1>powerful and versatile tool.

497
00:22:26.400 --> 00:22:28.720
<v Speaker 2>It really is. And you know, even though Cypress is

498
00:22:28.759 --> 00:22:32.240
<v Speaker 2>great for technical folks, sometimes we need to involve people

499
00:22:32.240 --> 00:22:35.519
<v Speaker 2>who aren't as familiar with code. That's where Cucumber comes in.

500
00:22:35.680 --> 00:22:37.960
<v Speaker 1>Cucumber that's one that uses plain English to write tests.

501
00:22:38.039 --> 00:22:41.519
<v Speaker 2>Right exactly. It uses a language called Girkin, which is

502
00:22:41.720 --> 00:22:45.400
<v Speaker 2>super readable and easy to understand even for non technical folks.

503
00:22:46.000 --> 00:22:49.920
<v Speaker 2>You write your tests using keywords like given, when, and then,

504
00:22:50.079 --> 00:22:51.640
<v Speaker 2>so it almost reads like a story.

505
00:22:52.079 --> 00:22:54.519
<v Speaker 1>So instead of writing code, you're basically writing out the

506
00:22:54.519 --> 00:22:57.039
<v Speaker 1>steps of the test in plain English. Right.

507
00:22:57.559 --> 00:23:00.519
<v Speaker 2>It's a great way to bridge the communication gap between

508
00:23:00.680 --> 00:23:03.799
<v Speaker 2>developers and stakeholders and to make sure everyone's on the

509
00:23:03.799 --> 00:23:06.519
<v Speaker 2>same page about what's being tested and what the expected

510
00:23:06.519 --> 00:23:07.240
<v Speaker 2>outcome should be.

511
00:23:07.400 --> 00:23:10.559
<v Speaker 1>So Cucumber is like a universal language for testing that

512
00:23:10.640 --> 00:23:12.519
<v Speaker 1>everyone can understand exactly.

513
00:23:12.559 --> 00:23:14.680
<v Speaker 2>And the best part is Cypress has built in support

514
00:23:14.680 --> 00:23:17.119
<v Speaker 2>for Cucumber, so you can write your tests in this

515
00:23:17.240 --> 00:23:20.359
<v Speaker 2>plain English format and Cypress will run them automatically.

516
00:23:20.519 --> 00:23:24.400
<v Speaker 1>That's awesome. It makes testing more collaborative and accessible to everyone.

517
00:23:24.680 --> 00:23:28.559
<v Speaker 2>Now, while all these testing tools and techniques are incredibly valuable,

518
00:23:28.839 --> 00:23:31.759
<v Speaker 2>it's important to remember that testing is ultimately about creating

519
00:23:31.839 --> 00:23:34.240
<v Speaker 2>software that meets the needs of our users.

520
00:23:34.599 --> 00:23:37.079
<v Speaker 1>Right. That's the core of the user centric.

521
00:23:36.720 --> 00:23:39.319
<v Speaker 2>Approach, and a big part of that is making sure

522
00:23:39.359 --> 00:23:42.799
<v Speaker 2>our apps are accessible to everyone, regardless of their abilities.

523
00:23:42.880 --> 00:23:45.599
<v Speaker 1>Accessibility is so important. I have a friend who uses

524
00:23:45.599 --> 00:23:48.720
<v Speaker 1>a screen reader and she's constantly running into websites and

525
00:23:48.759 --> 00:23:51.319
<v Speaker 1>apps that are just impossible to use.

526
00:23:51.440 --> 00:23:54.519
<v Speaker 2>It's a real shame, it is, But luckily RTL can

527
00:23:54.519 --> 00:23:58.240
<v Speaker 2>help us address these accessibility challenges by encouraging us to

528
00:23:58.319 --> 00:24:01.759
<v Speaker 2>test from the user's perspective. RTL naturally leads us to

529
00:24:01.799 --> 00:24:05.000
<v Speaker 2>consider how people with different needs and abilities will experience

530
00:24:05.000 --> 00:24:05.920
<v Speaker 2>our applications.

531
00:24:06.160 --> 00:24:09.319
<v Speaker 1>So if we're testing a form, for example, we might

532
00:24:09.359 --> 00:24:12.079
<v Speaker 1>make sure it can be navigated using only the keyboard,

533
00:24:12.640 --> 00:24:15.359
<v Speaker 1>or that it provides clear instructions for screen.

534
00:24:15.079 --> 00:24:18.319
<v Speaker 2>Readers exactly, And there are tools that can help us

535
00:24:18.319 --> 00:24:22.039
<v Speaker 2>with this. The book mentions just Acts, a library that

536
00:24:22.079 --> 00:24:25.720
<v Speaker 2>can run automated accessibility audits on your React components.

537
00:24:25.920 --> 00:24:28.680
<v Speaker 1>So it's like having an accessibility expert built right into

538
00:24:28.720 --> 00:24:30.480
<v Speaker 1>your testing process exactly.

539
00:24:30.839 --> 00:24:34.000
<v Speaker 2>By integrating just Acts into our workflow, we can catch

540
00:24:34.039 --> 00:24:38.039
<v Speaker 2>and fix accessibility issues early on before they impact our users.

541
00:24:38.279 --> 00:24:40.880
<v Speaker 1>This is all great stuff. It really feels like RTL

542
00:24:40.960 --> 00:24:43.920
<v Speaker 1>is a game changer for testing, especially for building user

543
00:24:43.960 --> 00:24:45.759
<v Speaker 1>centric and accessible applications.

544
00:24:45.920 --> 00:24:48.720
<v Speaker 2>I agree. It's a powerful approach that can really improve

545
00:24:48.759 --> 00:24:50.240
<v Speaker 2>the quality of the software we build.

546
00:24:50.400 --> 00:24:52.200
<v Speaker 1>Right. So we've covered a lot of ground in this

547
00:24:52.279 --> 00:24:54.759
<v Speaker 1>deep dies as we wrap things up, What are some

548
00:24:54.799 --> 00:24:57.319
<v Speaker 1>of the key takeaways you'd like our listeners to remember.

549
00:24:57.559 --> 00:25:00.079
<v Speaker 2>I think the biggest one is that RTL is more

550
00:25:00.119 --> 00:25:02.680
<v Speaker 2>than just a collection of tools and techniques. It's a

551
00:25:02.720 --> 00:25:07.200
<v Speaker 2>mindset shift towards user centric testing. It's about building software

552
00:25:07.279 --> 00:25:12.240
<v Speaker 2>that's not just functional, but also delightful, accessible, and truly

553
00:25:12.400 --> 00:25:15.640
<v Speaker 2>valuable to the people who use it. And remember, the

554
00:25:15.680 --> 00:25:19.000
<v Speaker 2>tools we talked about today are just the starting point.

555
00:25:19.319 --> 00:25:22.160
<v Speaker 2>The real power of RTL lies in its ability to

556
00:25:22.279 --> 00:25:25.079
<v Speaker 2>help us think differently about testing and build a culture

557
00:25:25.119 --> 00:25:27.039
<v Speaker 2>of quality in our development process.

558
00:25:27.400 --> 00:25:29.319
<v Speaker 1>I love that it's not just about the code, it's

559
00:25:29.319 --> 00:25:30.640
<v Speaker 1>about the people exactly.

560
00:25:31.319 --> 00:25:34.440
<v Speaker 2>So as you continue your journey with React Testing Library,

561
00:25:34.599 --> 00:25:36.759
<v Speaker 2>always remember to keep the user at the center of

562
00:25:36.759 --> 00:25:40.799
<v Speaker 2>your thinking. Ask yourself, how can my tests reflect the

563
00:25:40.839 --> 00:25:44.759
<v Speaker 2>real world experiences of my users and strive to create

564
00:25:44.839 --> 00:25:47.599
<v Speaker 2>software that not only works, but also makes a positive

565
00:25:47.599 --> 00:25:48.559
<v Speaker 2>impact on the world.

566
00:25:48.759 --> 00:25:51.759
<v Speaker 1>That's a fantastic message. Thanks for sharing your expertise with

567
00:25:51.839 --> 00:25:53.920
<v Speaker 1>us today. It's been a really eye opening conversation.

568
00:25:54.079 --> 00:25:56.359
<v Speaker 2>The pleasure was online. It's been great chatting about testing

569
00:25:56.799 --> 00:25:57.119
<v Speaker 2>all right.

570
00:25:57.160 --> 00:25:59.559
<v Speaker 1>Welcome back to our React Testing Library deep dive. I

571
00:25:59.559 --> 00:26:01.519
<v Speaker 1>feel like we've covered so much already, but I'm sure

572
00:26:01.519 --> 00:26:02.680
<v Speaker 1>there's even more to uncover.

573
00:26:03.039 --> 00:26:05.920
<v Speaker 2>Oh absolutely, We've gone deep on the tools and the

574
00:26:06.000 --> 00:26:08.079
<v Speaker 2>how to, But now I think it's time to like

575
00:26:09.720 --> 00:26:12.119
<v Speaker 2>zoom out a bit see the bigger picture of what

576
00:26:12.160 --> 00:26:12.720
<v Speaker 2>we've learned.

577
00:26:12.880 --> 00:26:16.319
<v Speaker 1>Okay, I like that. Yeah, So beyond just you know,

578
00:26:16.359 --> 00:26:19.720
<v Speaker 1>writing better tests, what's the bigger takeaway here?

579
00:26:19.799 --> 00:26:22.759
<v Speaker 2>Well, I think this whole shift toward user centric testing

580
00:26:23.160 --> 00:26:27.160
<v Speaker 2>it really changes how we think about software quality. It's

581
00:26:27.160 --> 00:26:30.640
<v Speaker 2>not just does the code work anymore? It's more about, like,

582
00:26:31.240 --> 00:26:33.440
<v Speaker 2>does this actually serve the people using it?

583
00:26:33.519 --> 00:26:35.079
<v Speaker 1>Right? Because at the end of the day, we're building

584
00:26:35.119 --> 00:26:37.440
<v Speaker 1>stuff for humans, not for computers exactly.

585
00:26:37.519 --> 00:26:40.720
<v Speaker 2>And this user centric idea it goes way beyond just software.

586
00:26:40.799 --> 00:26:44.079
<v Speaker 2>Think about any product you use, your car, your phone, website.

587
00:26:44.319 --> 00:26:46.759
<v Speaker 1>Yeah, they've all been designed with the user in mind,

588
00:26:46.799 --> 00:26:47.200
<v Speaker 1>haven't they.

589
00:26:47.279 --> 00:26:49.079
<v Speaker 2>For sure, the best products are the ones that just

590
00:26:49.200 --> 00:26:52.400
<v Speaker 2>like fit seamlessly into your life. They anticipate what you need,

591
00:26:52.440 --> 00:26:53.920
<v Speaker 2>they make the experience enjoyable.

592
00:26:54.160 --> 00:26:57.000
<v Speaker 1>And that's what RTL helps us do with software. By

593
00:26:57.039 --> 00:26:59.359
<v Speaker 1>focusing on the user, we can build apps that are

594
00:26:59.400 --> 00:27:02.799
<v Speaker 1>not just functional, but also intuitive and fun to use,

595
00:27:02.920 --> 00:27:04.359
<v Speaker 1>things that people actually want.

596
00:27:04.160 --> 00:27:07.359
<v Speaker 2>To use You nailed it, And there's another piece to

597
00:27:07.839 --> 00:27:12.839
<v Speaker 2>this user centric approach accessibility, making sure our apps work

598
00:27:12.920 --> 00:27:16.960
<v Speaker 2>for everyone, regardless of their abilities. That's not just about

599
00:27:17.039 --> 00:27:21.319
<v Speaker 2>being ethically responsible, it's about creating a truly user friendly

600
00:27:21.400 --> 00:27:22.920
<v Speaker 2>experience for everyone.

601
00:27:23.160 --> 00:27:25.079
<v Speaker 1>Yeah, that's a really good point. I've got a friend

602
00:27:25.079 --> 00:27:27.880
<v Speaker 1>who uses a screen reader and she's always running into

603
00:27:28.279 --> 00:27:31.440
<v Speaker 1>websites and apps that are just impossible to navigate. It's

604
00:27:31.480 --> 00:27:32.720
<v Speaker 1>a huge problem.

605
00:27:32.599 --> 00:27:35.039
<v Speaker 2>It really is, and thankfully URTL can help a lot

606
00:27:35.079 --> 00:27:38.039
<v Speaker 2>with that. When we're testing from the user's point of view,

607
00:27:38.319 --> 00:27:41.279
<v Speaker 2>we naturally start thinking about how people with different abilities

608
00:27:41.480 --> 00:27:42.359
<v Speaker 2>might use our app.

609
00:27:42.519 --> 00:27:44.759
<v Speaker 1>So like if we're testing a form, we might make

610
00:27:44.759 --> 00:27:47.119
<v Speaker 1>sure it works well with just the keyboard, or that

611
00:27:47.200 --> 00:27:50.440
<v Speaker 1>it gives clear instructions for screen reader users exactly.

612
00:27:50.519 --> 00:27:52.480
<v Speaker 2>And there are even tools to help with this. The

613
00:27:52.480 --> 00:27:55.000
<v Speaker 2>book talked about jest acts, which is a library that

614
00:27:55.039 --> 00:27:58.440
<v Speaker 2>can run automated accessibility checks on your React components.

615
00:27:58.680 --> 00:28:01.000
<v Speaker 1>So it's like having an accessibility the expert built right

616
00:28:01.000 --> 00:28:02.880
<v Speaker 1>into your testing process.

617
00:28:02.480 --> 00:28:05.839
<v Speaker 2>Pretty much, and by using just x you can catch

618
00:28:05.880 --> 00:28:09.240
<v Speaker 2>those accessibility issues early on before they become a problem

619
00:28:09.279 --> 00:28:10.039
<v Speaker 2>for your users.

620
00:28:10.279 --> 00:28:12.440
<v Speaker 1>That's awesome. Okay, So as we wrap up our deep

621
00:28:12.480 --> 00:28:15.039
<v Speaker 1>dive into React Testing Library, What are some of the

622
00:28:15.079 --> 00:28:17.680
<v Speaker 1>key takeaways you want our listeners to walk away with.

623
00:28:17.960 --> 00:28:20.519
<v Speaker 2>Well, first off, I want to emphasize again that RTL

624
00:28:20.599 --> 00:28:23.960
<v Speaker 2>isn't just a testing library. It's a whole philosophy, a

625
00:28:24.000 --> 00:28:27.039
<v Speaker 2>way of thinking about quality from the user's point of view.

626
00:28:27.079 --> 00:28:30.839
<v Speaker 1>It's about building software that's not just functional, but delightful

627
00:28:30.839 --> 00:28:34.480
<v Speaker 1>to use. Yeah, accessible to everyone, and something that genuinely

628
00:28:34.519 --> 00:28:36.200
<v Speaker 1>brings value to people exactly.

629
00:28:36.599 --> 00:28:38.839
<v Speaker 2>And all these tools and techniques we talked about, they're

630
00:28:38.839 --> 00:28:41.720
<v Speaker 2>just the beginning. The real magic of RTL is how

631
00:28:41.759 --> 00:28:44.920
<v Speaker 2>it changes our mindset about testing and helps us build

632
00:28:44.960 --> 00:28:46.799
<v Speaker 2>a culture of quality in our teams.

633
00:28:47.000 --> 00:28:48.920
<v Speaker 1>Yeah, it's not just about the code, it's about the

634
00:28:48.920 --> 00:28:49.920
<v Speaker 1>people for sure.

635
00:28:50.079 --> 00:28:53.839
<v Speaker 2>So to everyone listening as you start exploring React Testing Library,

636
00:28:54.240 --> 00:28:56.240
<v Speaker 2>keep the user at the heart of everything you do.

637
00:28:56.640 --> 00:28:59.920
<v Speaker 2>Think about how your tests can reflect real world use cases,

638
00:29:00.279 --> 00:29:02.759
<v Speaker 2>and always try to build software that not only works,

639
00:29:02.759 --> 00:29:05.119
<v Speaker 2>but also makes a positive difference in the world.

640
00:29:05.599 --> 00:29:07.880
<v Speaker 1>That's a great message to end on. Thanks so much

641
00:29:07.880 --> 00:29:09.839
<v Speaker 1>for joining us on this deep dive into a React

642
00:29:09.880 --> 00:29:12.480
<v Speaker 1>testing library. It's been an awesome and inspiring conversation.

643
00:29:12.799 --> 00:29:15.200
<v Speaker 2>My pleasure I always love talking about testing.

644
00:29:15.160 --> 00:29:17.400
<v Speaker 1>And to our listeners, thanks for tuning in to this

645
00:29:17.480 --> 00:29:20.640
<v Speaker 1>deep dive. We hope you learned a lot about React testing,

646
00:29:21.160 --> 00:29:24.559
<v Speaker 1>Keep learning, keep exploring, and keep building amazing software.
