You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/guides/guides/stubs-spies-and-clocks.md
+9-9Lines changed: 9 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -70,8 +70,8 @@ You generally stub a function when it has side effects you are trying to control
70
70
- You have a function that accepts a callback, and want to invoke the callback.
71
71
- Your function returns a `Promise`, and you want to automatically resolve or reject it.
72
72
- You have a function that wraps `window.location` and don't want your application to be navigated.
73
-
- You're trying to test your applications "failure path" by forcing things to fail.
74
-
- You're trying to test your applications "happy path" by forcing things to pass.
73
+
- You're trying to test your application's "failure path" by forcing things to fail.
74
+
- You're trying to test your application's "happy path" by forcing things to pass.
75
75
- You want to "trick" your application into thinking it's logged in or logged out.
76
76
- You're using `oauth` and want to stub login methods.
77
77
@@ -81,7 +81,7 @@ You generally stub a function when it has side effects you are trying to control
81
81
82
82
## Spies
83
83
84
-
A spy gives you the ability to "spy" on a function, by being able to capture and then assert that the function was calling with the right arguments, or that the function was called a certain number of times, or even what the return value or context the function was called with.
84
+
A spy gives you the ability to "spy" on a function, by being able to capture and then assert that the function was called with the right arguments, or that the function was called a certain number of times, or even what the return value was, or what context the function was called with.
85
85
86
86
A spy does **not** modify the behavior of the function - it is left perfectly intact. A spy is most useful when you are testing the contract between multiple functions and you don't care about the side effects the real function may create (if any).
87
87
@@ -95,15 +95,15 @@ cy.spy(obj, "method")
95
95
96
96
## Clock
97
97
98
-
There are situations when it is useful to control your applications`date` and `time` in order to force its behavior or avoid slow tests.
98
+
There are situations when it is useful to control your application's`date` and `time` in order to force its behavior or avoid slow tests.
99
99
100
100
{% url `cy.clock()` clock %} gives you the ability to control:
101
101
102
102
-`Date`
103
103
-`setTimeout`
104
104
-`setInterval`
105
105
106
-
***Common Scenarios:***
106
+
***Common Scenarios***
107
107
108
108
- You're polling something in your application with `setInterval` and want to control that.
109
109
- You have **throttled** or **debounced** functions which you want to control.
@@ -182,10 +182,10 @@ Beyond just integrating these tools together we have also extended and improved
182
182
183
183
- We replaced Sinon's argument stringifier for a much less noisy, more performant, custom version.
184
184
- We improved the `sinon-chai` assertion output by changing what displays during a passing vs failing test.
185
-
- We've added aliasing support to `stub` and `spy` API's.
185
+
- We added aliasing support to `stub` and `spy` API's.
186
186
- We automatically restore and teardown `stub`, `spy`, and `clock` between tests.
187
187
188
-
We also integrated all of these API's directly into the Command Log so you can visually see what's happening in your application.
188
+
We also integrated all of these API's directly into the Command Log, so you can visually see what's happening in your application.
189
189
190
190
***We visually indicate when:***
191
191
@@ -197,11 +197,11 @@ When you use aliasing with the {% url `.as()` as %} command, we also correlate t
197
197
198
198
When stubs are created by calling the method `.withArgs(...)` we also visually link these together.
199
199
200
-
When you click on a stub or spy we also output **incredibly** helpful debugging information.
200
+
When you click on a stub or spy, we also output **incredibly** helpful debugging information.
201
201
202
202
***For instance we automatically display:***
203
203
204
204
- The call count (and total number of calls)
205
-
- The arguments without transforming them (they are the real arguments)
205
+
- The arguments, without transforming them (they are the real arguments)
0 commit comments