Skip to content

fix: bug fixes, performance, and DX improvements#456

Merged
quantizor merged 7 commits into
mainfrom
fix/issue-triage-v7.3.1
Mar 22, 2026
Merged

fix: bug fixes, performance, and DX improvements#456
quantizor merged 7 commits into
mainfrom
fix/issue-triage-v7.3.1

Conversation

@quantizor

@quantizor quantizor commented Mar 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Benchmarked with 50 styled components:

  • toHaveStyleRule: 5.6x faster with cache enabled
  • Snapshot serialization: 14.3x faster with cache enabled

Credits: @jdeniau (#449), @shoosya (#451), @ilyary (#452), @jantimon (#446) for the original reports and PRs that informed several of these fixes.

@changeset-bot

changeset-bot Bot commented Mar 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 22ceda9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
jest-styled-components Patch

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

This comment was marked as outdated.

- 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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/utils.js Outdated
Comment thread src/utils.js Outdated
- 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
@quantizor quantizor merged commit caf69b9 into main Mar 22, 2026
2 checks passed
@quantizor quantizor deleted the fix/issue-triage-v7.3.1 branch March 22, 2026 04:47
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

Successfully merging this pull request may close these issues.

2 participants