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() supporting objects #2320

Closed
blasvicco opened this issue Aug 10, 2018 · 5 comments
Closed

Cypress.env() supporting objects #2320

blasvicco opened this issue Aug 10, 2018 · 5 comments

Comments

@blasvicco
Copy link

blasvicco commented Aug 10, 2018

Current behavior:

If we try to set an object as env variable we get an error.

Desired behavior:

It will be great if we can set objects in the env variables.

Versions

Beta 3.0.3

@funnylookinhat
Copy link

As an example - we have an environment-specific options object that we frequently want to pass to cy.visit that include HTTP Auth, etc.; it'd simplify things greatly if we could just: cy.visit('/foobar', Cypress.env('visitOptions'));

@jennifer-shehane
Copy link
Member

@blasvicco Could you explain how you are trying to set your env variable? There are 5 ways they can be set - so we want to make sure to address your issue appropriately. https://on.cypress.io/environment-variables#Setting

@funnylookinhat Cypress.env() should accept an object, as is described in the docs. Make sure you are passing the object literal and not the string 'visitOptions'.

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label Aug 10, 2018
@blasvicco
Copy link
Author

@jennifer-shehane Following this
We have in our plugin js index file the next lines:

module.exports = (on, config) => {
  config.env.visit_options = {
      auth: {
        password: 'test',
        username: 'test_something',
      },
  };
  console.log(config);
  return config;
};

When we run cypress we are able to see that the config has the env.visit_options set properly but in the cypress window we are getting this error:
screen shot

@jennifer-shehane jennifer-shehane added stage: investigating Someone from Cypress is looking into this and removed stage: needs information Not enough info to reproduce the issue labels Aug 13, 2018
@jennifer-shehane
Copy link
Member

Yes, this does throw this error. Console.log of env options in config:

{ 
  env: { visit_options: { auth: [Object] } }
 }

@jennifer-shehane jennifer-shehane removed the stage: investigating Someone from Cypress is looking into this label Aug 13, 2018
@jennifer-shehane
Copy link
Member

Now that I see your use case, there is an open issue for this here: #1736

Going to close as duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants