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

Nested env variables do not get parsed #4865

Closed
aldo-roman opened this issue Jul 29, 2019 · 4 comments
Closed

Nested env variables do not get parsed #4865

aldo-roman opened this issue Jul 29, 2019 · 4 comments
Labels
type: duplicate This issue or pull request already exists

Comments

@aldo-roman
Copy link

aldo-roman commented Jul 29, 2019

Current behavior:
Cypress does not parse object env variables. Example:

// none of these gets parsed
export CYPRESS_REPORTER_OPTIONS=mochaFile=path/to/report.xml
export CYPRESS_REPORTER_OPTIONS='mochaFile=path/to/report.xml'
export CYPRESS_REPORTER_OPTIONS=mochaFile='path/to/report.xml'
export CYPRESS_REPORTER_OPTIONS={'mochaFile':'path/to/report.xml'}

This happens because the getProcessEnvVars function expects only string or boolean values:

getProcessEnvVars: (obj = {}) ->
_.reduce obj, (memo, value, key) ->
if isCypressEnvLike(key)
memo[removeEnvPrefix(key)] = coerce(value)
memo
, {}

module.exports = function (value) {
const num = _.toNumber(value)
const bool = toBoolean(value)
return _
.chain([num, bool])
.find(isValue(value))
.defaultTo(value)
.value()

Expected behavior
Parse nested env variables, similar to what is done for args

const sanitizeAndConvertNestedArgs = function (str) {

@cypress-bot cypress-bot bot added the stage: needs investigating Someone from Cypress needs to look at this label Jul 30, 2019
@GMchris
Copy link

GMchris commented Oct 31, 2019

I ran into this problem as well. I'm not sure what the idea behind it is, however I'm currently JSON.stringify-ing my objects to sidestep it. I'm curious whether this is intentional or not.

@jennifer-shehane
Copy link
Member

Closing as duplicate of #1736

@jennifer-shehane jennifer-shehane added type: duplicate This issue or pull request already exists and removed stage: needs investigating Someone from Cypress needs to look at this labels Jan 3, 2020
@jordandlaman
Copy link

jordandlaman commented Sep 10, 2020

I am wondering why this was closed as a duplicate of #1736 as this specifically pertains to how CYPRESS_* vars get parsed when setting CYPRESS_REPORTER_OPTIONS when #1736 pertains to deeply nested values in the plugins section? Have tested this in 4.11.0 when #1736 was merged in and using CYPRESS_REPORTER_OPTIONS from the command line is still a no go.

@jennifer-shehane
Copy link
Member

For more complex configuration objects, you may want to consider passing a JSON.stringified object surrounded by single quotes.

CYPRESS_REPORTER_OPTIONS='{"mochaFile":"path/to/report.xml}'

plugins/index.js

module.exports = (on, config) => {
  console.log(config) // see what all is in here!
  
  // return config
  return config
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

4 participants