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

Error: "cy.task() must only be invoked from the spec file or support file" when calling cy.task() #29192

Open
distante opened this issue Mar 25, 2024 · 2 comments
Labels
stage: needs investigating Someone from Cypress needs to look at this

Comments

@distante
Copy link

Current behavior

When overwritten cy.log, cy.task can not be called because it fails with > cy.task() must only be invoked from the spec file or support file.

  Cypress.Commands.overwrite('log', (subject, message) =>
    cy.task('cyLog', message)
  );

Desired behavior

That code can be used as it was before.

Test code to reproduce

on commands.ts:

  Cypress.Commands.overwrite('log', (subject, message) =>
    cy.task('cyLog', message)
  );

on index-ts

  on(`task`, {
    cyLog(message) {
      // eslint-disable-next-line no-console
      console.log(ansi.magenta('cy.log:'), ansi.magenta(message));

      return null;
    },
  });

Cypress Version

13.6.4

Node version

v20.11.0

Operating System

macOS 14.4

Debug Logs

No response

Other

This issue should be similar to the closed #28336.

@cypress-app-bot
Copy link
Collaborator

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

@cypress-app-bot cypress-app-bot added the stale no activity on this issue for a long period label Sep 26, 2024
@distante
Copy link
Author

AFAIK, still an issue.

@cypress-app-bot cypress-app-bot removed the stale no activity on this issue for a long period label Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage: needs investigating Someone from Cypress needs to look at this
Projects
None yet
Development

No branches or pull requests

3 participants