fix: bug fixes, performance, and DX improvements#456
Merged
Conversation
🦋 Changeset detectedLatest commit: 22ceda9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
- Fix native toHaveStyleRule crash when element has no style prop (#225, #110) - Fix nested at-rules (@media inside @supports) not found (#245) - Fix getHTML() creating empty ServerStyleSheet instead of reading from the global sheet (#401) - Fix selector matching with spaces around CSS combinators (> ~ +) - Add descriptive CSS parse error messages with context and caret (#147) - Add opt-in CSS parse caching via enableCSSCache/disableCSSCache - Normalize whitespace in value comparisons (commas, slashes, !important) - Improve validation messages: property not found vs value mismatch - Use Set for O(1) hash lookups, non-mutating serializer AST - Hoist selector normalization out of O(n*m) loop - Filter rule.type before spreading in getRules - Extract invalidateCSSCache() to encapsulate cache internals
Add 'jest-styled-components/cache' entry point that enables CSS parse caching. Scope lint-staged biome check to source directories only since test files use ESM imports incompatible with biome's CJS parser.
- Add edgeCases.spec.js: modern CSS, weird values, selectors, cache stress - Add cssCache.spec.js: enable/disable, invalidation, mid-test growth - Add cacheIntegrity.spec.js: cross-test isolation, snapshot correctness - Add nested at-rules test (#245) and native no-style-prop tests (#225) - Add CSS parse error formatting tests (#147)
- Add changeset for v7.3.1 patch release - Document CSS parse caching in README - Add snapshot preservation and bug ownership rules to AGENTS.md - Add cache/ to biome includes
023f028 to
ca9440b
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 19 out of 21 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Fix getCSSForMatcher returning null after a parse error by only updating cache state after successful parse - Fix normalizeValueSpacing regex to handle escaped quotes inside strings (e.g. content: "hello \"world\"")
…CSSCache - Add @container and @layer to AT_RULE_TYPES for matcher and serializer - Export disableCSSCache from cache entry point - Flatten nested RN style arrays with .flat(Infinity) - Strengthen escaped-quote test to assert exact value - Add cache AST integrity test (matcher + serializer in same test) - Add nested style array test for React Native - Fix error message grammar ("Could not find" vs "Could neither find") - Update typings with container and layer options - Document @container and @layer in README
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
toHaveStyleRulecrash when element has nostyleprop (Cannot read property 'style' or 'filter' of undefined (react-native) #225, React-Native: TypeError: Cannot read property 'filter' of undefined #110)@mediainside@supportsand vice versa) not found bytoHaveStyleRule(toHaveStyleRule fails with media and supports option parameters #245)getHTML()creating an emptyServerStyleSheetinstead of reading from the global sheet (getHTML() is failing, not sure why. #401)> ul > li > a)import 'jest-styled-components/cache'for fastertoHaveStyleRulein large test suites (styleSheetSerializer extremely slow #235)@containerand@layerat-rule support fortoHaveStyleRuleand the snapshot serializerred !important,sidebar / inline-size, andrgb(0, 0, 0)match their stylis-formatted equivalentsdisableCSSCachefromjest-styled-components/cacheentry pointSetfor O(1) hash lookups (was O(n) array.includes())Benchmarked with 50 styled components:
toHaveStyleRule: 5.6x faster with cache enabledCredits: @jdeniau (#449), @shoosya (#451), @ilyary (#452), @jantimon (#446) for the original reports and PRs that informed several of these fixes.