-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Upgrading to 0.8.0 will break imports from outside of the test's directory #1145
Comments
I should note that if you remove this line: the test will pass. Also, they will pass if you revert the regex change from this commit: a298cbb |
This appears to be related to #1147 |
The problem seems to be that the Now it would be great if Jest allowed matching on the full path instead of just the module name, but since it doesn't seem to be possible at the moment, it looks like we need to revert the |
Thanks for getting the hot fix out so quickly. 👍 |
Yes, thank you very much! Really appreciated! |
If you are reporting a bug, please fill in below. Otherwise feel free to remove this template entirely.
Can you reproduce the problem with latest npm?
Yes. npm 4.0.3
Description
After upgrading to react-scripts
0.8.0
tests that import files or utilities from outside the current testing directory return'test-file-stub'
as the default (and undefined, of course, for any destructured imports).Expected behavior
In the prior version of react-scripts, importing utilities into tests worked as expected. If you had a
utils
directory in yoursrc
and you imported it into a test running in another directory insrc
, you would have access to to the imported code. For example:Where in the test file
books.test.js
:The test would run and if you logged out the
range
function, you would see that it was the function you expected. In the prior release, you could make use of your utility functions in your tests as well as import other items for assisting in your testing.Actual behavior
If you log out
range
, you'll seetest-file-stub
. This happens with any import outside of the directory with the test.Environment
Run these commands in the project folder and fill in their results:
npm ls react-scripts
(if you haven’t ejected):node -v
:npm -v
:Then, specify:
Operating system:
Mac OS X 10.11.6
Browser and version:
Firefox 50
Reproducible Demo
I've created 2 versions to show the behavior in
0.7.0
and0.8.0
and included them in this repo: https://github.com/adregan/create-react-app-issueThe text was updated successfully, but these errors were encountered: