Skip to content

Cypress.env() return value is garbled when multibyte string in 3.5.0 #5435

Closed
@aomoriringo

Description

@aomoriringo

Current behavior:

Return value of Cypress.env() is garbled when cypress.env.json includes multibyte string.

Desired behavior:

Return value of Cypress.env() is not garbled.

On cypress 3.4.1, I got desired behavior.

Steps to reproduce: (app code and test code)

  • Create following files
// cypress/integration/garbled_test.js
const myenv = Cypress.env()
describe('garbled test', function() {
  it('garbled test', function() {
    expect(myenv.alphabet).to.equal('aiueo')
    expect(myenv.multibyte).to.equal('あいうえお')
  })
})

cypress.env.json

{
  "alphabet": "aiueo",
  "multibyte": "あいうえお"
}

あいうえお is Japanese characters.

  • Execute $ npx cypress open and select garbled_test.js

image

Versions

  • Cypress 3.5.0
  • macOS Mojave

Activity

jennifer-shehane

jennifer-shehane commented on Oct 24, 2019

@jennifer-shehane
Member

Thank you so much for providing a full reproducible example. I also see this behavior with the code provided. I can also confirm that this is a regression introduced in 3.5.0

3.4.1

Screen Shot 2019-10-24 at 8 41 33 AM

3.5.0

Screen Shot 2019-10-24 at 8 43 12 AM

I have confirmed that this also takes place when setting the Environment Variable in the following ways:

  • Via cypress.env.json
  • Via env object in cypress.json
  • Via CYPRESS_multibyte=あいうえお cypress open in terminal
  • Via --env multibyte=あいうえお in terminal
  • Via plugins file, setting config

The env var shows up correctly in the configuration panel in the Desktop GUI.

Screen Shot 2019-10-24 at 8 50 29 AM

changed the title [-]Cypress.env() return value is garbled in 3.5.0[/-] [+]Cypress.env() return value is garbled when multibyte string in 3.5.0[/+] on Oct 24, 2019
bahmutov

bahmutov commented on Oct 24, 2019

@bahmutov
Contributor

I have added a failing test in branch unicode-env-variables see cypress-io/cypress-example-recipes#353

self-assigned this
on Oct 24, 2019
bahmutov

bahmutov commented on Oct 24, 2019

@bahmutov
Contributor

The env variables are incorrectly encoded in the runner block, which comes from runner/static/index.html

Runner.start(document.getElementById('app'), "{{{base64Config}}}")

Screen Shot 2019-10-24 at 9 52 37 AM

bahmutov

bahmutov commented on Oct 24, 2019

@bahmutov
Contributor

Added logging env variables on the server side

cypress:server:runner serving runner index.html with config { version: '3.5.0', platform: 'darwin', arch: 'x64', projectName: 'server-communication__env-variables', env: { 'my-var': 'ok', 'unicode-var': 'привет', CACHE_FOLDER: '' } }
cypress-bot

cypress-bot commented on Oct 24, 2019

@cypress-bot
Contributor

The code for this is done in cypress-io/cypress#5451, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

cypress-bot

cypress-bot commented on Nov 5, 2019

@cypress-bot
Contributor

Released in 3.6.0.

locked as resolved and limited conversation to collaborators on Dec 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

type: regressionA bug that didn't appear until a specific Cy version releasev3.5.0 🐛Issue present since 3.5.0

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @aomoriringo@jennifer-shehane@bahmutov

    Issue actions

      Cypress.env() return value is garbled when multibyte string in 3.5.0 · Issue #5435 · cypress-io/cypress