Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
776 views
in Technique[技术] by (71.8m points)

execute describe() block only after before() hook completes execution in cypress

Iam trying to run different set of tests (spec files) for different users in Cypress. So as a result I import all tests in one file and run the tests whichever is applicable for that user. To check which spec files to run, I have written code in before() hook

  import * as all_spec_files from "../../../support/all-imports";

  before(() => {
    Cypress.Cookies.debug(true);
    cy.server();
    cy.login();
    cy.visit("/", { failOnStatusCode: false });
    files.push("alchemy_wifi_privacy_settings");
    files.push("alchemy_wifi_promotions");
  });

Now in describe() block I iterate files array and execute the test.The code is as below

  describe("All Menus", () => {
    files.forEach(file => {
      all_spec_files[file]();
    });
  });

The problem is the code in describe() block gets executed before the before() hook. So files array is always empty. How can I wait describe() block from executing until before() hook has finished in Cypress

question from:https://stackoverflow.com/questions/65881821/execute-describe-block-only-after-before-hook-completes-execution-in-cypress

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...