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

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

Closed
aomoriringo opened this issue Oct 24, 2019 · 6 comments · Fixed by #5451
Closed

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

aomoriringo opened this issue Oct 24, 2019 · 6 comments · Fixed by #5451
Assignees
Labels
type: regression A bug that didn't appear until a specific Cy version release v3.5.0 🐛 Issue present since 3.5.0

Comments

@aomoriringo
Copy link

aomoriringo commented Oct 24, 2019

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
@cypress-bot cypress-bot bot added the stage: investigating Someone from Cypress is looking into this label Oct 24, 2019
@jennifer-shehane
Copy link
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

@jennifer-shehane jennifer-shehane added the type: regression A bug that didn't appear until a specific Cy version release label Oct 24, 2019
@jennifer-shehane jennifer-shehane 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 Oct 24, 2019
@bahmutov
Copy link
Contributor

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

@bahmutov bahmutov self-assigned this Oct 24, 2019
@bahmutov
Copy link
Contributor

bahmutov commented Oct 24, 2019

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
Copy link
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 bot added stage: work in progress stage: needs review The PR code is done & tested, needs review stage: ready for work The issue is reproducible and in scope and removed stage: investigating Someone from Cypress is looking into this stage: work in progress stage: needs review The PR code is done & tested, needs review labels Oct 24, 2019
@cypress-bot cypress-bot bot added stage: work in progress stage: needs review The PR code is done & tested, needs review and removed stage: ready for work The issue is reproducible and in scope stage: work in progress labels Oct 24, 2019
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Oct 24, 2019

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 bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Oct 24, 2019
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Nov 5, 2019

Released in 3.6.0.

@jennifer-shehane jennifer-shehane added the v3.5.0 🐛 Issue present since 3.5.0 label Dec 10, 2019
@cypress-io cypress-io locked as resolved and limited conversation to collaborators Dec 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: regression A bug that didn't appear until a specific Cy version release v3.5.0 🐛 Issue present since 3.5.0
Projects
None yet
3 participants