File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -257,7 +257,7 @@ cy.tick(waitMilliseconds);
257
257
cy .get (' #logoutNotification' ).should (' be.visible' );
258
258
```
259
259
260
- ## Tip: Smart delays
260
+ ## Tip: Smart delays and retries
261
261
Cypress will automatically wait (and retry) for many async things e.g.
262
262
```
263
263
// If there is no request against the `foo` alias cypress will wait for 4 seconds automatically
@@ -267,6 +267,24 @@ cy.get('#foo')
267
267
```
268
268
This keeps you from having to constantly add arbitrary timeout (and retry) logic in your test code flow.
269
269
270
+
271
+ ## Tip: Unit testing applicaiton code
272
+ You can also use cypress to unit test your application code in isolation e.g.
273
+
274
+ ``` js
275
+ import { once } from ' ../../../src/app/utils' ;
276
+
277
+ // Later
278
+ it (' should only call function once' , () => {
279
+ let called = 0 ;
280
+ const callMe = once (()=> called++ );
281
+ callMe ();
282
+ callMe ();
283
+ expect (called).to .equal (1 );
284
+ });
285
+ ```
286
+
287
+
270
288
## Resources
271
289
* Website: https://www.cypress.io/
272
290
* Write your first cypress test (gives a nice tour of the cypress IDE) : https://docs.cypress.io/guides/getting-started/writing-your-first-test.html
You can’t perform that action at this time.
0 commit comments