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

Use default theme when ThemeProvider isn't included in the tree #801

Closed
mlynam opened this issue Mar 26, 2020 · 4 comments
Closed

Use default theme when ThemeProvider isn't included in the tree #801

mlynam opened this issue Mar 26, 2020 · 4 comments

Comments

@mlynam
Copy link

mlynam commented Mar 26, 2020

Describe the bug
When using testing a component that uses useThemeUI the them object is initialized to null.

To Reproduce
Steps to reproduce the behavior:

  1. Unit test a component that uses the useThemeUI hook.

Expected behavior
Without a ThemeProvider in the tree, the theme object returned from useThemeUI should return a default that includes expected properties so we don't need to use a ThemeProvider for every test.

@flo-sch
Copy link
Collaborator

flo-sch commented May 11, 2020

Wouldn't that be anti-pattern with how theme-ui works?

Not sure which test runner you are using, but with jest, you can easily add a "wrapper" to provide a theme for your unit tests (ideally the same theme that you use in your app)

It is even illustrated the official documentation from testing-library (if that is the one you are using):
https://testing-library.com/docs/react-testing-library/setup

Most of the test runners and utilities out there allow for wrapping components ;)

@jxnblk
Copy link
Member

jxnblk commented May 12, 2020

I'm guessing this is related to the notion of a "default theme", which might be removed in v1: related #832

@lachlanjc
Copy link
Member

I think the direction we’re moving in (as Brent mentioned) is away from having a default theme & this isn’t something we’re planning to support.

@hasparus close?

@mlynam
Copy link
Author

mlynam commented Nov 14, 2020

Understood.

@mlynam mlynam closed this as completed Nov 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants