Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lifecycle hooks (before:run, after:run, before:spec, after:spec) are not working in v13 #27953

Closed
alexkirillovtech opened this issue Oct 2, 2023 · 1 comment

Comments

@alexkirillovtech
Copy link

alexkirillovtech commented Oct 2, 2023

Current behavior

I'm trying to use lifecycle hooks in my code, but they are not executed

Desired behavior

Code inside hooks events to be executed

Test code to reproduce

export default defineConfig({
viewportWidth: 1920,
viewportHeight: 1080,
fixturesFolder: "./test/cypress/fixtures",
screenshotsFolder: "./test/cypress/screenshots",
videosFolder: "./test/cypress/videos",
downloadsFolder: "./test/cypress/downloads",
experimentalStudio: true,
experimentalWebKitSupport: true,
e2e: {
experimentalRunAllSpecs: true,
supportFile: "./test/cypress/support/e2e.ts",
specPattern: "test/cypress/e2e/**/*.cy.ts",
setupNodeEvents(on) {
on("before:browser:launch", (browser: Cypress.Browser, launchOptions) => {
console.log("in before:browser:launch.....");

    if (browser.name === "chrome" || browser.name === "chromium") {
      const existing = launchOptions.args.find(
        (arg) => arg.slice(0, 23) === "--remote-debugging-port"
      );

      debuggingPort = existing.split("=")[1];

      console.log("debuggingPort", debuggingPort);
    }
    return launchOptions;
  });
  on("before:run", async () => {
    console.log("before:run");
  });
  on("after:run", async () => {
    console.log("after:run");
  });
  on("before:spec", async () => {
    console.log("before:spec");
  });
  on("after:spec", async () => {
    console.log("after:spec");
  });
  on("task", {
    async joinMeeting({ meetingId, token }) {
      console.log("Debugging port is: " + debuggingPort);
      return joinMeeting(meetingId, token, debuggingPort);
    },
    async closeAllPuppeteerTabs() {
      return closeAllPuppeteerTabs(debuggingPort);
    },
  });
},

},
});

Cypress Version

13.3.0

Node version

v18.14.2

Operating System

macOS 13.4.1

Debug Logs

No response

Other

No response

@alexkirillovtech alexkirillovtech changed the title Lifecycle hooks (before:run, after:run, before:spec, after:spec) are not working Lifecycle hooks (before:run, after:run, before:spec, after:spec) are not working in v13 Oct 2, 2023
@alexkirillovtech
Copy link
Author

Yep, closing this one, I should have set experimentalInteractiveRunEvents: true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant