-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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 preset and Yarn Workspaces #17469
Comments
I've been running into this issue as well. Any updates here? |
Recently jumped onto react-native and jest and ran into this recently as well. Curious what the plan is. |
I'm encountering the same issue. Does anyone knows if there is a tracking tracking issue in the jest repository ? |
Looks like someone created a ticket, then closed it out with their own symlink-heavy workaround (?): jestjs/jest#5325 I think this is maybe worth reopening? |
I've been hacking away at this, seems I can get things working by adding these to my jest config in my package.json Babelrc file also needs to be in root or you'll probably have transpiling related errors. |
Full reproduction in isolation in Lerna with steps here: Minimal setup that I could muster
Readme has steps to see tests broken after deps were hoisted by lerna (or yarn workspaces, but I didn't document that) |
I proceeded trying to manually map all the things that it wasn't finding by hand, hoping I could find some pattern that I was missing. This list is the point at which I ran out of beer and gave up.
What it does seem to say is that react-native is having a lot of problems finding itself. In setup.js you can clearly see :
is a bunch of things that its going to mock, which seems totally reasonable, but its trying to resolve those locations first. Where I'm getting lost here is that all of those things such as |
I tried out @Smtih's jest config example, replacing Like @kcjonson says, it seems like React Native is having trouble locating dependencies, not Jest. |
Thanks for posting this! It looks like you may not be using the latest version of React Native, v0.53.0, released on January 2018. Can you make sure this issue can still be reproduced in the latest version? I am going to close this, but please feel free to open a new issue if you are able to confirm that this is still a problem in v0.53.0 or newer. |
This message was created automatically by mail delivery software.
A message that you sent could not be delivered to one or more of its
recipients. This is a temporary error. The following address(es) deferred:
[email protected]
Domain salmanwaheed.info has exceeded the max emails per hour (170/150 (113%)) allowed. Message will be reattempted later
…------- This is a copy of the message, including all the headers. ------
Received: from o3.sgmail.github.com ([192.254.112.98]:59161)
by box1177.bluehost.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128)
(Exim 4.89_1)
(envelope-from <[email protected]>)
id 1epQVP-003JCK-No
for [email protected]; Fri, 23 Feb 2018 20:28:12 -0700
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=github.com;
h=from:reply-to:to:cc:in-reply-to:references:subject:mime-version:content-type:content-transfer-encoding:list-id:list-archive:list-post:list-unsubscribe;
s=s20150108; bh=bM5MrtZHzQa+TPra7AXAek0a2/Q=; b=m0rYBSMSQ1dHmlbZ
rgRfaeDZdIo1VKuCnuXW4ck1BGvevk+i0ffaVureLU3yWOqRGo/Yi2cgopRZYYpL
rWOzpEtkNhicj7OqXiZrWoqhci/IXWSveWLbG6ezcxdBVfvNFqXIk6HygRas9uTv
GW1PbOKfR2YlLaQxX/AAk/7y9ds=
Received: by filter0463p1iad2.sendgrid.net with SMTP id filter0463p1iad2-17542-5A90DBBF-9
2018-02-24 03:27:59.34583192 +0000 UTC
Received: from github-smtp2b-ext-cp1-prd.iad.github.net (github-smtp2b-ext-cp1-prd.iad.github.net [192.30.253.17])
by ismtpd0001p1iad1.sendgrid.net (SG) with ESMTP id tMjvGpX1QNqRP0P7Rl0iBA
for <[email protected]>; Sat, 24 Feb 2018 03:27:59.242 +0000 (UTC)
Date: Sat, 24 Feb 2018 03:27:59 +0000 (UTC)
From: React Native Bot <[email protected]>
Reply-To: facebook/react-native <[email protected]>
To: facebook/react-native <[email protected]>
Cc: Subscribed <[email protected]>
Message-ID: <facebook/react-native/issues/17469/[email protected]>
In-Reply-To: <facebook/react-native/issues/[email protected]>
References: <facebook/react-native/issues/[email protected]>
Subject: Re: [facebook/react-native] Jest preset and Yarn Workspaces (#17469)
Mime-Version: 1.0
Content-Type: multipart/alternative;
boundary="--==_mimepart_5a90da87643e3_46ff2ad14466eec4586121";
charset=UTF-8
Content-Transfer-Encoding: 7bit
Precedence: list
X-GitHub-Sender: react-native-bot
X-GitHub-Recipient: salmanwaheed
X-GitHub-Reason: subscribed
List-ID: facebook/react-native <react-native.facebook.github.com>
List-Archive: https://github.com/facebook/react-native
List-Post: <mailto:[email protected]>
List-Unsubscribe: <mailto:unsub+00ef1b38819af7f9620304bef3af4c959dbca191470e601292cf0000000116a89c8792a169ce11140b67@reply.github.com>,
<https://github.com/notifications/unsubscribe/AO8bOGuQzAeobkzexkvbohibgVeQ-KHpks5tX4CHgaJpZM4RVdtO>
X-Auto-Response-Suppress: All
X-GitHub-Recipient-Address: [email protected]
X-SG-EID: 92ws1MVnlto3blxqXlf5goB0ee0kdDGWR6vcWx8d64/ORbZMLxn3DLojABGrc2Fpz/o/sW2OB9EWZY
aWZRSSqkOuB82ykVgx+V7ePqelPGEuxg0XZEcQGxgxFq03hqhpkEVLb3yUuapJVZHJCiTzo0txCOUK
5yWUXeC5QdCUpifIz5nHqBu2PWTfGVA05GpyMIpvW0wuAd18moKdiNZBpU9NnCt8fYZH+Gnzod1vPp
U=
X-Spam-Status: No, score=-1.1
X-Spam-Score: -10
X-Spam-Bar: -
X-Ham-Report: Spam detection software, running on the system "box1177.bluehost.com",
has NOT identified this incoming email as spam. The original
message has been attached to this so you can view it or label
similar future email. If you have any questions, see
root\@localhost for details.
Content preview: Thanks for posting this! It looks like you may not be using
the latest version of React Native, v0.53.0, released on January 2018. Can
you make sure this issue can still be reproduced in the latest version? [...]
Content analysis details: (-1.1 points, 5.0 required)
pts rule name description
---- ---------------------- --------------------------------------------------
0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked.
See
http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block
for more information.
[URIs: github.com]
-0.5 SPF_PASS SPF: sender matches SPF record
-0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay
domain
0.0 HTML_IMAGE_ONLY_32 BODY: HTML: images with 2800-3200 bytes of words
0.0 HTML_MESSAGE BODY: HTML included in message
-0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's
domain
-0.1 DKIM_VALID Message has at least one valid DKIM or DK signature
0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid
-0.4 AWL AWL: Adjusted score from AWL reputation of From: address
X-Spam-Flag: NO
----==_mimepart_5a90da87643e3_46ff2ad14466eec4586121
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Thanks for posting this! It looks like you may not be using the latest vers=
ion of React Native, v0.53.0, released on January 2018. Can you make sure t=
his issue can still be reproduced in the latest version?=20
I am going to close this, but please feel free to open a new issue if you a=
re able to confirm that this is still a problem in v0.53.0 or newer.
<sub>[How to Contribute](https://facebook.github.io/react-native/docs/contr=
ibuting.html#bugs) =E2=80=A2 [What to Expect from Maintainers](https://face=
book.github.io/react-native/docs/maintainers.html#handling-issues)</sub>
--=20
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
#17469 (comment)=
----==_mimepart_5a90da87643e3_46ff2ad14466eec4586121
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<p>Thanks for posting this! It looks like you may not be using the latest v=
ersion of React Native, v0.53.0, released on January 2018. Can you make sur=
e this issue can still be reproduced in the latest version?</p>
<p>I am going to close this, but please feel free to open a new issue if yo=
u are able to confirm that this is still a problem in v0.53.0 or newer.</p>
<p><sub><a href=3D"https://facebook.github.io/react-native/docs/contributin=
g.html#bugs" rel=3D"nofollow">How to Contribute</a> =E2=80=A2 <a href=3D"ht=
tps://facebook.github.io/react-native/docs/maintainers.html#handling-issues=
" rel=3D"nofollow">What to Expect from Maintainers</a></sub></p>
<p style=3D"font-size:small;-webkit-text-size-adjust:none;color:#666;">&mda=
sh;<br />You are receiving this because you are subscribed to this thread.<=
br />Reply to this email directly, <a href=3D"https://github.com/facebook/r=
eact-native/issues/17469#issuecomment-368194915">view it on GitHub</a>, or =
<a href=3D"https://github.com/notifications/unsubscribe-auth/AO8bOGmQaB-HUj=
lcg3BHrO_N4crPlPDQks5tX4CHgaJpZM4RVdtO">mute the thread</a>.<img alt=3D"" h=
eight=3D"1" src=3D"https://github.com/notifications/beacon/AO8bOJHPygQDJqSL=
lOaM8LPOvA2aA_yNks5tX4CHgaJpZM4RVdtO.gif" width=3D"1" /></p>
<div itemscope itemtype=3D"http://schema.org/EmailMessage">
<div itemprop=3D"action" itemscope itemtype=3D"http://schema.org/ViewAction=
">
<link itemprop=3D"url" href=3D"https://github.com/facebook/react-native/i=
ssues/17469#issuecomment-368194915"></link>
<meta itemprop=3D"name" content=3D"View Issue"></meta>
</div>
<meta itemprop=3D"description" content=3D"View this Issue on GitHub"></meta>
</div>
<script type=3D"application/json" data-scope=3D"inboxmarkup">{"api_version"=
:"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"Gi=
tHub"},"entity":{"external_key":"github/facebook/react-native","title":"fac=
ebook/react-native","subtitle":"GitHub repository","main_image_url":"https:=
//cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95f=
c-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com=
/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":=
{"name":"Open in GitHub","url":"https://github.com/facebook/react-native"}}=
,"updates":{"snippets":[{"icon":"PERSON","message":"@react-native-bot in #1=
7469: Thanks for posting this! It looks like you may not be using the lates=
t version of React Native, v0.53.0, released on January 2018. Can you make =
sure this issue can still be reproduced in the latest version? \n\nI am goi=
ng to close this, but please feel free to open a new issue if you are able =
to confirm that this is still a problem in v0.53.0 or newer.\n\n\u003csub\u=
003e[How to Contribute](https://facebook.github.io/react-native/docs/contri=
buting.html#bugs) =E2=80=A2 [What to Expect from Maintainers](https://faceb=
ook.github.io/react-native/docs/maintainers.html#handling-issues)\u003c/sub=
\u003e\n\n"}],"action":{"name":"View Issue","url":"https://github.com/faceb=
ook/react-native/issues/17469#issuecomment-368194915"}}}</script>=
----==_mimepart_5a90da87643e3_46ff2ad14466eec4586121--
|
Still occurring. |
For people still struggling with this i got a yarn workflow friendly fix, not pretty but it'll help us until the root of the issue is fixed. Instead of defining
Same thing would apply to babel-jest
Another option would probably be to ignore the rootDir which should have the same effect, you'd have to make sure that the dependency is correct and that is installed on somewhere otherwise i'll end up using the global module if installed. In this case it could be simplified to:
|
Yarn now supports a |
Quick and dirty fix for this: {
"workspaces": {
"packages": ["packages/*"],
"nohoist": "**/*"
}
} I tried being conservative on what I wasn't hoisting, but for the take of productivity, I just disabled hoisting altogether. |
@ohwillie what's the point of doing this? Don't you lose all the advantages of workspaces? |
You still get the single |
If you'd like to be more granular, you can start by |
This is a bit of a nightmare, if Yarn supported per-project nohoist then there would be an easy option, but instead I had to blanket nohoist both |
Yarn does support per-package nohoisting, if that’s what you’re looking for. That said, I still haven’t figured out a simple way to handle this issue with react-native, so I’m still nohoisting everything in my project :(
|
It only supports per-package on private packages for some reason. Trying to add it into the package.json of a public package will throw an error. I'm not sure why the distinction is made for this feature. |
Could it cause issues for consumers of the package that aren’t part of the workspace? (Just spitballing here)
|
Is there any plan to fix this in react-native? |
This worked for me: justinsisley/Jest-CSS-Modules#13 (comment) |
Thank you @HeberLZ for giving a workaround which resolves the problem, without having to compromise on yarn workspace advantages (which you lose when using nohoist). |
Is this a bug report?
Yes, or maybe incompatibility with a Yarn feature is more accurate
Have you read the Contributing Guidelines?
Yes
Environment
Environment:
OS: macOS Sierra 10.12.6
Node: 8.9.1
Yarn: 1.3.2
npm: 5.5.1
Watchman: 4.7.0
Xcode: Xcode 9.2 Build version 9C40b
Android Studio: 2.2 AI-145.3360264
Packages: (wanted => installed)
react: 16.0.0
react-native: 0.51.0
Target Platform: N/A
Steps to Reproduce
react-native init rnproject
rm -rf rnproject/node_modules
package.json
:yarn
cd rnproject
yarn test
Expected Behavior
React Native's jest preset should work with projects using yarn workspaces, where modules may not be in the project's
node_modules
directory (they may be hoisted in the parent dir'snode_modules
.)Actual Behavior
The jest preset provided by React Native specifies
<rootDir>/node_modules/...
in a couple places, which is not always the location of certain modules (i.e. when using Yarn workspaces):Thus, Jest produces an error saying that it can't find the files in the right spots.
The Yarn documentation on workspaces is opinionated on making assumptions about the package layout, I tend to agree:
But I'm also not sure how to achieve a layout-agnostic kind of a setup.
Reproducible Demo
https://github.com/dingbat/ws-rn-bug-example
Some fixes I tried
--rootDir ..
). This caused a bunch more errors and didn't seem like a good direction, because we should be able to run tests isolated to a subdir anyway.node_modules
. Tried this with and without"preset": "react-native"
, neither one workedModule <rootDir>/node_modules/react-native/jest/setup.js in the setupFiles option was not found.
Cannot find module 'setupDevtools' from 'setup.js'
rnproject/node_modules/react-native
tonode_modules/react-native
(not a real solve since this wouldn't survive Git and would have to be some sort of build step). No luck, for some reason Jest still can't find the asset transformer:Note
My intuition tells me there's no easy fix in this repo, and there's much better luck of addressing it in the Jest repo. But since the broken jest-preset configuration is provided in this repo, I thought it would make more sense to open an issue here.
The text was updated successfully, but these errors were encountered: