@@ -437,3 +437,205 @@ Feature: pretty output
437437 Scenario: a scenario # cypress/e2e/a.feature:2
438438 Given a step
439439 """
440+
441+ @network
442+ Rule: it should handle reloads gracefully in a multitude of scenarios
443+
444+ Reloading occurs when visiting or configuring baseUrl to a new domain, either different from the
445+ preconfigured value or because no value was configured to begin with. This forces Cypress to
446+ reload the window, re-fire before:spec event and re-run the current test.
447+
448+ Background :
449+ Given a file named "cypress/e2e/a.feature" with:
450+ """
451+ Feature: a feature
452+ @env(origin="https://duckduckgo.com/")
453+ Scenario: a scenario
454+ Given a step
455+
456+ @env(origin="https://google.com/")
457+ Scenario: another scenario
458+ Given another step
459+ """
460+
461+ Scenario : base case
462+ Given a file named "cypress/support/step_definitions/steps.js" with:
463+ """
464+ const { Given } = require("@badeball/cypress-cucumber-preprocessor");
465+
466+ Given("a step", function() {});
467+
468+ Given("another step", function() {});
469+ """
470+ When I run cypress
471+ Then it passes
472+ And the output should contain
473+ """
474+ Feature: a feature # cypress/e2e/a.feature:1
475+
476+ @env(origin="https://duckduckgo.com/")
477+ Scenario: a scenario # cypress/e2e/a.feature:3
478+ Given a step
479+
480+ @env(origin="https://google.com/")
481+ Scenario: another scenario # cypress/e2e/a.feature:7
482+ Given another step
483+ """
484+
485+ Scenario : reloading within steps
486+ Given a file named "cypress/support/step_definitions/steps.js" with:
487+ """
488+ const { Given } = require("@badeball/cypress-cucumber-preprocessor");
489+
490+ Given("a step", function() {
491+ cy.visit("https://duckduckgo.com/");
492+ });
493+
494+ Given("another step", function() {
495+ cy.visit("https://google.com/");
496+ });
497+ """
498+ When I run cypress
499+ Then it passes
500+ And the output should contain
501+ """
502+ Feature: a feature # cypress/e2e/a.feature:1
503+
504+ @env(origin="https://duckduckgo.com/")
505+ Scenario: a scenario # cypress/e2e/a.feature:3
506+ Given a step
507+
508+ Reloading..
509+
510+ Feature: a feature # cypress/e2e/a.feature:1
511+
512+ @env(origin="https://duckduckgo.com/")
513+ Scenario: a scenario # cypress/e2e/a.feature:3
514+ Given a step
515+
516+ @env(origin="https://google.com/")
517+ Scenario: another scenario # cypress/e2e/a.feature:7
518+ Given another step
519+
520+ Reloading..
521+
522+ Feature: a feature # cypress/e2e/a.feature:1
523+
524+ @env(origin="https://google.com/")
525+ Scenario: another scenario # cypress/e2e/a.feature:7
526+ Given another step
527+ """
528+
529+ Scenario : reloading in before()
530+ Given a file named "cypress/support/step_definitions/steps.js" with:
531+ """
532+ const { Given } = require("@badeball/cypress-cucumber-preprocessor");
533+
534+ before(() => {
535+ cy.visit("https://duckduckgo.com/");
536+ });
537+
538+ Given("a step", function() {});
539+
540+ Given("another step", function() {});
541+ """
542+ When I run cypress
543+ Then it passes
544+ And the output should not contain "Reloading.."
545+
546+ Scenario : reloading in after()
547+ Given a file named "cypress/support/step_definitions/steps.js" with:
548+ """
549+ const { Given } = require("@badeball/cypress-cucumber-preprocessor");
550+
551+ after(() => {
552+ cy.visit("https://duckduckgo.com/");
553+ });
554+
555+ Given("a step", function() {});
556+
557+ Given("another step", function() {});
558+ """
559+ When I run cypress
560+ Then it passes
561+ And the output should contain
562+ """
563+ Feature: a feature # cypress/e2e/a.feature:1
564+
565+ @env(origin="https://duckduckgo.com/")
566+ Scenario: a scenario # cypress/e2e/a.feature:3
567+ Given a step
568+
569+ @env(origin="https://google.com/")
570+ Scenario: another scenario # cypress/e2e/a.feature:7
571+ Given another step
572+
573+ Reloading..
574+
575+ Feature: a feature # cypress/e2e/a.feature:1
576+
577+ @env(origin="https://google.com/")
578+ Scenario: another scenario # cypress/e2e/a.feature:7
579+ Given another step
580+ """
581+
582+ Scenario : reloading in beforeEach()
583+ Given a file named "cypress/support/step_definitions/steps.js" with:
584+ """
585+ const { Given } = require("@badeball/cypress-cucumber-preprocessor");
586+
587+ beforeEach(() => {
588+ cy.visit(Cypress.env("origin"));
589+ });
590+
591+ Given("a step", function() {});
592+
593+ Given("another step", function() {});
594+ """
595+ When I run cypress
596+ Then it passes
597+ And the output should not contain "Reloading.."
598+
599+ Scenario : reloading in afterEach()
600+ Given a file named "cypress/support/step_definitions/steps.js" with:
601+ """
602+ const { Given } = require("@badeball/cypress-cucumber-preprocessor");
603+
604+ afterEach(() => {
605+ cy.visit(Cypress.env("origin"));
606+ });
607+
608+ Given("a step", function() {});
609+
610+ Given("another step", function() {});
611+ """
612+ When I run cypress
613+ Then it passes
614+ And the output should contain
615+ """
616+ Feature: a feature # cypress/e2e/a.feature:1
617+
618+ @env(origin="https://duckduckgo.com/")
619+ Scenario: a scenario # cypress/e2e/a.feature:3
620+ Given a step
621+
622+ Reloading..
623+
624+ Feature: a feature # cypress/e2e/a.feature:1
625+
626+ @env(origin="https://duckduckgo.com/")
627+ Scenario: a scenario # cypress/e2e/a.feature:3
628+ Given a step
629+
630+ @env(origin="https://google.com/")
631+ Scenario: another scenario # cypress/e2e/a.feature:7
632+ Given another step
633+
634+ Reloading..
635+
636+ Feature: a feature # cypress/e2e/a.feature:1
637+
638+ @env(origin="https://google.com/")
639+ Scenario: another scenario # cypress/e2e/a.feature:7
640+ Given another step
641+ """
0 commit comments