Patch Changes
-
c7b0e4e: Bug Fixes
- Fix native
toHaveStyleRulecrash when element has nostyleprop (#225, #110) - Fix nested at-rules (
@mediainside@supportsand vice versa) not being found bytoHaveStyleRule(#245) - Fix
getHTML()creating an emptyServerStyleSheetinstead of reading from the global sheet (#401) - Fix selector matching with spaces around CSS combinators (
> ul > li > anow matches correctly) - Fix invalid CSS causing cryptic parse errors — now shows the offending rule with surrounding context and a caret pointing at the exact error position (#147)
- Fix nested React Native style arrays not flattening correctly
Improvements
- Add
@containerand@layerat-rule support fortoHaveStyleRuleand the snapshot serializer - Add opt-in CSS parse caching via
import 'jest-styled-components/cache'for fastertoHaveStyleRulein large test suites (#235) - Normalize whitespace in value comparisons so
red !important,sidebar / inline-size, andrgb(0, 0, 0)match their stylis-formatted equivalents (skips quoted strings) - Clearer validation messages: "Property not found" instead of cryptic crash, human-readable options formatting, better negation wording
- Export
disableCSSCachefromjest-styled-components/cacheentry point - Add
cache/index.d.tsfor TypeScript users importing the cache entry point - Use
Setfor hash lookups (O(1) vs O(n) per lookup) - Serializer no longer mutates the parsed CSS AST
Credits: @jdeniau (#449), @shoosya (#451), @ilyary (#452), @jantimon (#446)
- Fix native