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

Add overrideConfig option for the react-scripts test script #1659

Closed

Conversation

cjbuchmann
Copy link

@cjbuchmann cjbuchmann commented Feb 27, 2017

Hey all, new contributor here. While I'm really enjoying all of the greatness that this project has to offer, I've run up against a few issues when it comes to testing that would be easily solved by adding my own jest configuration.

Unfortunately the jest configuration appears to be inaccessible to the user, so this branch attempts to allow the user the ability to configure this as needed. From what I understand, I could add my own config by ejecting the react-scripts, but that seems a little too heavy handed.

I also understand that this might go against the core value of 'convention over configuration', so if you'd prefer to avoid this approach, that's fine too.

In particular, I've been following along with jest not running tests inside of /src/node_modules. In my case, I'm also getting import errors SyntaxError: Unexpected token import during testing that is resolved by adding

  "transformIgnorePatterns": [
    "<rootDir>/(node_modules)/"
  ]

to the jest config. But I don't see any way of adding my own config options to the jest config at the present time. (If there is, I'd definitely appreciate that feedback).

Thanks!

Usage

you can define your own config options in a json file
config.json

{
    "transformIgnorePatterns": [
    "<rootDir>/(node_modules)/"
  ]
}

You can then specify that json file in package.json

"test": "react-scripts test --env=jsdom  --overrideConfig=config.json",

the options will be merged with (and can override) the existing configuration options

The jest config is inaccessible to users. While it adds great defaults,
it would be nice for users to specify their own configuration options
on top of the existing app provided defaults. This branch enables that
ability.
@gaearon
Copy link
Contributor

gaearon commented Feb 27, 2017

Thanks for PR. I don't think we'll be adding this in near future, but we're happy to address individual use cases.

If you have specific issues (e.g. Jest running files that it shouldn't) please file an issue describing those problems and we might just fix them by default for everyone. Thanks!

@gaearon gaearon closed this Feb 27, 2017
@cjbuchmann
Copy link
Author

cjbuchmann commented Feb 28, 2017

thanks @gaearon, but there already is an issue open in regards to my problem. #607 and #1081 address it pretty well.

However, it seems like it's stumbling over road blocks and has been open for a while. If there's anything that I can do to speed that along, please let me know

Thanks!

@gaearon
Copy link
Contributor

gaearon commented May 16, 2017

Some options are configurable in the next version.
#1830

@gaearon
Copy link
Contributor

gaearon commented May 16, 2017

Please help beta test the new version that includes this change!
#2172

@lock lock bot locked and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants