Comments (4)
@crevulus This isn't specific to polished. It applies to anything that requires access to the theme
object for your tests to pass. This is an older put relevant thread: styled-components/styled-components#1319
from polished.
@bhough Thanks for your help.
For anyone with the same issue: the answer is to wrap with a ThemeProvider
, similar to how they've done it in the Setup section of testing-library's docs: https://testing-library.com/docs/react-testing-library/setup/#custom-render
from polished.
@crevulus This is almost always due to not properly mocking props.theme
. I'd suggest logging out the value of props.theme.primary
in your tests to see what it contains. That error likely means you aren't getting the hex value you think you are when you run in your test environment.
from polished.
@bhough Thanks for your feedback. I haven't mocked theme
at all. Didn't realise that was a requirement when using polished -- it works fine for other places where I'm using theme
so just assumed.
To "properly" mock theme, should I follow this snippet?
const renderComponent = ({ theme, name }) =>
render(
<ThemeProvider theme={theme}>
<HelloMessageStyled name={name} />
</ThemeProvider>
);
it('renders greeting', async () => {
const { getByText } = renderComponent({ theme: mockThemeObject, name: 'Maggie' });
await waitForElement(() => getByText(/hello Maggie/i));
});
from polished.
Related Issues (20)
- [Feature request] Rgba to rgb conversion fuction HOT 1
- Add unit selection to between mixin HOT 1
- Lighten red color dont work HOT 1
- `getValueAndUnit` return type is misleading HOT 1
- Test suite fails to run with cssVar() HOT 3
- Unable to play in browser console on Polished's site HOT 3
- `parseToHsl` Doesn't seem to parse valid CSS Colors 4 space-separated values HOT 9
- rgbaRegex fails 3 digit decimals HOT 3
- Mix doesn't output the same value as vanilla SCSS HOT 1
- [Feature request] Add function to convert between rgb and hex notation HOT 1
- Readable color returnIfDarkColor isn't working HOT 4
- [Possible improvements] I found some places I could improve performance and Bundle size HOT 1
- Typescript Error
- Polished "playground" on homepage doesn't work
- parseToRgb / parseToHsl float precision expected by the regex
- Website contrast prevents readibility
- WARN node_modules/polished/lib/color/rgb.js (6:59) A comment 15:14:25 "/*#__PURE__*/" in "node_modules/polished/lib/color/rgb.js" contains an annotation that Rollup cannot interpret due to the position of the comment. The comment will be removed to avoid issues. HOT 3
- Breaking semver change introduced in v4.3.0 HOT 6
- Use `exports` field with `.mjs` extension instead of `"module": "dist/polished.esm.js"` in `package.json`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from polished.