@@ -17,9 +17,9 @@ title: Writing and Organizing Tests
17
17
18
18
<strong class =" alert-header " >Best Practices</strong >
19
19
20
- We recently gave a "Best Practices" conference talk at AssertJS (February 2018).
21
- This video demonstrates how to approach breaking down your application and
22
- organizing your tests.
20
+ We gave a "Best Practices" conference talk at AssertJS (February 2018). This
21
+ video demonstrates how to approach breaking down your application and organizing
22
+ your tests.
23
23
24
24
<Icon name =" play-circle " ></Icon >
25
25
[ https://www.youtube.com/watch?v=5XQOK0v_YRE ] ( https://www.youtube.com/watch?v=5XQOK0v_YRE )
@@ -564,17 +564,6 @@ it.skip('returns "fizz" when number is multiple of 3', () => {
564
564
565
565
### Test Isolation
566
566
567
- <Alert type =" warning " >
568
-
569
- <strong class =" alert-header " ><Icon name =" exclamation-triangle " ></Icon >
570
- Experimental</strong >
571
-
572
- The concept of test isolation is currently experimental, and can be enabled by
573
- setting the [ ` experimentalSessionAndOrigin ` ] ( /guides/references/experiments )
574
- option to ` true ` in the Cypress config.
575
-
576
- </Alert >
577
-
578
567
<Alert type =" success " >
579
568
580
569
<Icon name =" check-circle " color =" green " ></Icon > ** Best Practice:** Tests should
@@ -619,19 +608,8 @@ and `off`.
619
608
620
609
###### On Mode
621
610
622
- <Alert type =" warning " >
623
-
624
- <strong class =" alert-header " ><Icon name =" exclamation-triangle " ></Icon >
625
- Experimental</strong >
626
-
627
- ` on ` mode is currently experimental and can be enabled by setting
628
- the [ ` experimentalSessionAndOrigin ` ] ( /guides/references/experiments ) flag
629
- to ` true ` in the Cypress config. This is the default test isolation behavior
630
- when using the ` experimentalSessionAndOrigin ` experiment.
631
-
632
- </Alert >
633
-
634
- When in ` on ` mode, Cypress resets the browser context _ before_ each test by:
611
+ This is the default test isolation behavior in Cypress. When in ` on ` mode,
612
+ Cypress resets the browser context _ before_ each test by:
635
613
636
614
- clearing the dom state by visiting ` about:blank `
637
615
- clearing [ cookies] ( /api/cypress-api/cookies ) in all domains
@@ -652,28 +630,18 @@ is so tests can reliably pass when run standalone or in a randomized order.
652
630
653
631
###### Off Mode
654
632
655
- <Alert type =" warning " >
656
-
657
- <strong class =" alert-header " ><Icon name =" exclamation-triangle " ></Icon >
658
- Experimental</strong >
659
-
660
- ` off ` mode is currently experimental and can be enabled by setting
661
- the [ ` experimentalSessionAndOrigin ` ] ( /guides/references/experiments ) flag
662
- to ` true ` in the Cypress config.
663
-
664
- </Alert >
665
-
666
633
When in ` off ` mode, Cypress will not alter the browser context before the test
667
634
starts. The page does not clear between tests and cookies, local storage and
668
635
session storage will be available across tests in that suite. Additionally, the
669
636
` cy.session() ` command will only clear the current browser context when
670
637
establishing the browser session - the current page will not clear.
671
638
672
- It is important to note that turning test isolation ` off ` may improve the
673
- overall performance of end-to-end tests, however, previous tests could be impact
674
- the browser state. It is important to be extremely mindful of how test are
675
- written when using this mode and ensure tests continue to run independent from
676
- one other.
639
+ It is important to note that while turning test isolation ` off ` may improve the
640
+ overall performance of end-to-end tests, it can however cause state to "leak"
641
+ between tests. This can make later tests dependent on the results of earlier
642
+ tests, and potentially cause misleading test failures. It is important to be
643
+ extremely mindful of how tests are written when using this mode, and ensure that
644
+ tests continue to run independently of one another.
677
645
678
646
###### Mode Comparison
679
647
@@ -686,13 +654,16 @@ one other.
686
654
687
655
Cypress only support testIsolation ` on ` in component testing.
688
656
689
- When running component tests, the browser context will allow start in a clean
690
- slate because Cypress will
657
+ When running component tests, Cypress resets the browser context _ before _ each
658
+ test by:
691
659
692
- - clear the page
693
- - clear [ cookies] ( /api/cypress-api/cookies )
694
- - clear
660
+ - clearing the page
661
+ - clearing [ cookies] ( /api/cypress-api/cookies )
662
+ - clearing
695
663
[ ` localStorage ` ] ( https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage )
664
+ - clearing
665
+ [ ` sessionStorage ` ] ( https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage )
666
+ in all domains
696
667
697
668
### Test Configuration
698
669
0 commit comments