Skip to content

cy.intercept request.body is ArrayBuffer for JSON requests with long Cyrillic strings #16292

@KarKarbI4

Description

@KarKarbI4

Current behavior

When sending request with cyrillic strings in json data to url, stubbed by cy.intercept, request.body object is ArrayBuffer, not plain object.

// intercept some url with any data
cy.intercept(URL, {
  body: { result: 'ok' },
}).as('testRequest');

// send json request with cyrillic string in data (length must be more than 6)
sendRequest({name: "Фрауиванович"})
cy.wait('@testRequest')
    .its('request')
    .then((req) => {
      console.log(req.body); // is ArrayBuffer object, not plain object
});

// send json request without cyrillic in data
sendRequest({name: "FrausIvanovich"})
cy.wait('@testRequest')
    .its('request')
    .then((req) => {
      console.log(req.body); // is plain object, as expected
});

Desired behavior

When sending request with cyrillic strings in json data to url, stubbed by cy.intercept, request.body is plain object

// send json request with cyrillic string in data (length must be more than 6)
sendRequest({name: "Фрауиванович"})
cy.wait('@testRequest')
    .its('request')
    .then((req) => {
      console.log(req.body); // is plain object
});

Test code to reproduce

Test code to reproduce: https://github.com/KarKarbI4/cypress-cyrillic-intercept-issue/blob/main/cypress/integration/spec.js
Test repo: https://github.com/KarKarbI4/cypress-cyrillic-intercept-issue

Versions

Cypress: cypress@7.1.0, cypress@7.2.0
Browser: Google Chrome 90
OS: MacOS Big Sur 11.2.3

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions