Descriptive error message when Theme context is not found #597
-
Hello, thanks for working on Paste! When using the Tooltip component and running the build on Jenkins, I ran into this error: After looking into this error, it would appear that it is due to the tests not having the theme context and so fontSize70 can't be read from the referenced theme. An error message that points that out to the user could help give more clarity when debugging something similar. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Thanks, @alecnicolas! That's a great point. I'll bring this up with the team and see what we can do. |
Beta Was this translation helpful? Give feedback.
-
Hi @alecnicolas, it's certainly not ideal and it trips folks up alot of the time. We've called it out in the getting started docs https://paste.twilio.design/getting-started/engineering#jest-testing but adding some kind of check might be beneficial in the long run. It's a little bit tricky to do right now as there are a few places we'd need to check based on certain component implementations. There isn't currently a central place where we could check, for any given component, are you in a theme provider. In the near future once all our components are just using It's definitely something we could consider in the future. Thanks for the suggestion 🎉 |
Beta Was this translation helpful? Give feedback.
Hi @alecnicolas, it's certainly not ideal and it trips folks up alot of the time. We've called it out in the getting started docs https://paste.twilio.design/getting-started/engineering#jest-testing but adding some kind of check might be beneficial in the long run.
It's a little bit tricky to do right now as there are a few places we'd need to check based on certain component implementations. There isn't currently a central place where we could check, for any given component, are you in a theme provider. In the near future once all our components are just using
Box
under the hood, we could just do a single check inside ofBox
. Check if there is atheme
, if not, console.error or something.I…