Skip to content

Commit ca9440b

Browse files
committed
docs: update changeset, README, AGENTS.md, and biome config
- 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
1 parent 4d37b70 commit ca9440b

4 files changed

Lines changed: 36 additions & 2 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
"jest-styled-components": patch
3+
---
4+
5+
**Bug Fixes**
6+
7+
- Fix native `toHaveStyleRule` crash when element has no `style` prop (#225, #110)
8+
- Fix nested at-rules (`@media` inside `@supports` and vice versa) not being found by `toHaveStyleRule` (#245)
9+
- Fix `getHTML()` creating an empty `ServerStyleSheet` instead of reading from the global sheet (#401)
10+
- Fix selector matching with spaces around CSS combinators (`> ul > li > a` now matches correctly)
11+
- 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)
12+
13+
**Improvements**
14+
15+
- Add opt-in CSS parse caching via `import 'jest-styled-components/cache'` for faster `toHaveStyleRule` in large test suites (#235)
16+
- Normalize whitespace in value comparisons so `red !important`, `sidebar / inline-size`, and `rgb(0, 0, 0)` match their stylis-formatted equivalents (skips quoted strings)
17+
- Clearer validation messages: "Property not found" instead of cryptic crash, human-readable options formatting, better negation wording
18+
- Add `cache/index.d.ts` for TypeScript users importing the cache entry point
19+
- Use `Set` for hash lookups (O(1) vs O(n) per lookup)
20+
- Serializer no longer mutates the parsed CSS AST

AGENTS.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ Uses `@adobe/css-tools` as the sole production dependency to parse stylesheet ou
122122

123123
- **Never mass-close or mass-comment.** Every response posted to an issue must be individually researched and evidence-backed with a fresh code experiment.
124124
- **Verify before closing.** Reproduce the reported scenario on the current version and confirm it's resolved before closing. Don't assume a fix covers an issue without testing.
125-
- **Be kind and appreciative.** Thank reporters for filing. Be respectful even when closing as stale or wontfix.
125+
- **Warm and positive tone.** Be honest but welcoming. Thank reporters for taking the time to file.
126+
- **Own bugs gracefully.** If the issue is an actual bug in the codebase, respectfully apologize (short and sweet) and prepare a well-researched, thoroughly tested candidate fix PR.
126127
- **Preserve original authorship.** When absorbing work from external PRs, credit the original author in the commit or PR description.
127128

128129
### PRs
@@ -132,6 +133,7 @@ Uses `@adobe/css-tools` as the sole production dependency to parse stylesheet ou
132133

133134
### Code
134135

136+
- **Never break downstream snapshots.** Changes to matcher logic or normalization must not alter snapshot output format. If our tests had a certain format, users likely have similar tests.
135137
- **Use TDD (red/green)** when fixing bugs — write the failing test first, then fix the code.
136138
- **Always run tests** before considering work done.
137139
- **Research before implementing.** Go beyond official docs — review dev blogs, expert content, and source code for the deepest understanding.

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,18 @@ import { resetStyleSheet } from 'jest-styled-components'
362362
resetStyleSheet()
363363
```
364364

365+
### CSS Parse Caching
366+
367+
By default, `toHaveStyleRule` re-parses the stylesheet on every assertion. For test suites with many assertions, this can be slow. Import the cached entry point to parse once and reuse the result when the stylesheet hasn't changed:
368+
369+
```js
370+
import 'jest-styled-components/cache'
371+
```
372+
373+
That's it—the cache automatically invalidates when the stylesheet changes (new components render) and when `resetStyleSheet` runs between tests via `beforeEach`. No manual cleanup needed.
374+
375+
With the cached entry point, both `toHaveStyleRule` and the snapshot serializer reuse the parsed stylesheet when possible. The serializer builds a filtered copy of the AST instead of mutating it during serialization.
376+
365377
## Legacy: Enzyme
366378

367379
[Enzyme](https://github.com/enzymejs/enzyme) is no longer actively maintained. If you still use it, snapshot testing requires [enzyme-to-json](https://www.npmjs.com/package/enzyme-to-json) and `toHaveStyleRule` works with both shallow and mounted wrappers. Consider migrating to `@testing-library/react`.

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
},
88
"files": {
99
"ignoreUnknown": true,
10-
"includes": ["src/**", "native/**", "serializer/**", "vitest/**", "test/**", "!test/native/**"]
10+
"includes": ["src/**", "native/**", "serializer/**", "vitest/**", "cache/**", "test/**", "!test/native/**"]
1111
},
1212
"formatter": {
1313
"enabled": true,

0 commit comments

Comments
 (0)