Skip to content

cy.task() doesn't work with new Cypress version 12.15.0 #27099

@Pavel-Lahutsin

Description

@Pavel-Lahutsin

Current behavior

With the latest Cypress version 12.15.0 cy.task() is broken. It says "cy.task() must only be invoked from the spec file or support file."

12 15 0
documentation

Desired behavior

It should work as in previous Cypress version

Test code to reproduce

cypress.config.js

const { defineConfig } = require('cypress')

module.exports = defineConfig({
  // setupNodeEvents can be defined in either
  // the e2e or component configuration
  e2e: {
    setupNodeEvents(on, config) {
      on('task', {
        log(message) {
          console.log(message)

          return null
        },
      })
    },
  },
})

spec.cy.js

describe("Test for bug ", () => {
    it(`should be working`, () => {
        cy.task('log', 'This will be output to the terminal')
    })
});

Cypress Version

12.15.0

Node version

16.15

Operating System

win10

Debug Logs

No response

Other

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions