Skip to content

Problem with cy.task() Cypress version 13.3.0  #28018

Closed
@Troyc-boop

Description

@Troyc-boop

Current behavior

Using cy.task() as in the example, but am getting the error message:
"CypressError: cy.task() must only be invoked from the spec file or support file."
Am having the same issue as reported here.
image

Desired behavior

It should work as it is described in the documentation

Test code to reproduce

In cypress.config I have added:
e2e: {
setupNodeEvents(on, config) {
on('task', {
log(message) {
console.log(message);

      return null;
    },
  });
}

}
image
and in the test just call the cy.task()
image

Cypress Version

13.3.0

Node version

18.13.0

Operating System

Ubuntu 23.04

Debug Logs

No response

Other

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions