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

cy.task not working with ArrayBuffer #27163

Closed
theJ3H opened this issue Jun 29, 2023 · 2 comments · Fixed by #27166
Closed

cy.task not working with ArrayBuffer #27163

theJ3H opened this issue Jun 29, 2023 · 2 comments · Fixed by #27166
Assignees
Labels
E2E Issue related to end-to-end testing Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. type: bug

Comments

@theJ3H
Copy link

theJ3H commented Jun 29, 2023

Current behavior

When using a task with a ArrayBuffer as argument, I get the error message cy.task() must only be invoked from the spec file or support file.

Using an array or a string as an argument works fine.

This is a problem when using cy.intercept and trying to send the intercept.body.response as an argument for a task, like validating the content of a intercepted pdf file.

This worked fine in Cypress 12.14.0

Desired behavior

Cypress should also allow ArrayBuffer to be passed as an argument. Alternatively there should be an explaination+documentation why ArrayBuffer is no longer supported as an argument, as the current error message is misleading.

Test code to reproduce

spec.cy.js

describe("Test for bug ", () => {
    it(`doesnt work`, () => {
        			
		const buffer = new ArrayBuffer(10);				
		cy.task("log", buffer)
		
    })
		
    it(`works`, () => {
        			
		const array = new Array(10);
		cy.task("log", array)
		
    })
	
});

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
        },
      })
    },
  },
})

Cypress Version

12.16.0

Node version

v18.12.1

Operating System

Win11

Debug Logs

No response

Other

Worked fine with older versions, the fix in 12.16.0 didn't help.

@chrisbreiding chrisbreiding self-assigned this Jun 29, 2023
@chrisbreiding chrisbreiding added type: bug E2E Issue related to end-to-end testing Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. labels Jun 29, 2023
@chrisbreiding
Copy link
Contributor

Thanks for the error report. I verified this is a bug and a fix should be out for it in the next release.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jul 6, 2023

Released in 12.17.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v12.17.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Jul 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
E2E Issue related to end-to-end testing Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants