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

Jest globals do not support arrays #2093

Closed
fkrauthan opened this issue Nov 15, 2016 · 3 comments
Closed

Jest globals do not support arrays #2093

fkrauthan opened this issue Nov 15, 2016 · 3 comments

Comments

@fkrauthan
Copy link

I usual use webpack in my project. With the help of the define plugin I have a global called __SERVERS__ that contains a array of server urls. The problem is that with jest globals I can not reproduce that effect. If I write something like this:

"__SERVERS__": [
        {
          "label": "local",
          "value": "https://localhost"
        }
      ],

Jest produces (type object):

{"0": {"label": "local", "value": "https://localhost"}}

Which is completely different to the expected value (type array):

[{"label": "local", "value": "https://localhost"}]
@cpojer
Copy link
Member

cpojer commented Nov 15, 2016

That may be an issue with Jest but I think the "globals" field should be deprecated and removed altogether. It isn't very useful.

I recommend creating a file that does:

global.__SERVERS__ = […];

and adding that to your setupFiles.

@cpojer cpojer closed this as completed Nov 15, 2016
@fkrauthan
Copy link
Author

Ok make sense. Yeah in that case I would remove it from the docs if thats the recommended way anyways.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants