Skip to content

Commit 983abd0

Browse files
committed
fix: address PR review feedback
- Clone RegExp in matcherTest to prevent lastIndex mutation with g/y flags - Add missing enableCSSCache/disableCSSCache types to vitest/index.d.ts - Revert prerelease version bump
1 parent 21194b1 commit 983abd0

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jest-styled-components",
3-
"version": "7.3.2-prerelease.0",
3+
"version": "7.3.2",
44
"description": "Jest utilities for Styled Components",
55
"type": "commonjs",
66
"packageManager": "pnpm@10.32.1",

src/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ const matcherTest = (received, expected, isNot) => {
256256
const normalizedReceived = normalizeValueSpacing(received);
257257

258258
if (expected instanceof RegExp) {
259-
return expected.test(normalizedReceived);
259+
return new RegExp(expected).test(normalizedReceived);
260260
}
261261

262262
// Support asymmetric matchers (e.g. expect.stringContaining()) from any framework

vitest/index.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ export declare const styleSheetSerializer: NewPlugin & {
1515
/** Reset the styled-components stylesheet between tests. Called automatically via `beforeEach` when using this entry point. */
1616
export declare const resetStyleSheet: () => void;
1717

18+
/** Enable caching of parsed CSS. Improves performance when styles don't change between assertions. */
19+
export declare const enableCSSCache: () => void;
20+
21+
/** Disable and clear the CSS parse cache. */
22+
export declare const disableCSSCache: () => void;
23+
1824
interface AsymmetricMatcher {
1925
$$typeof: Symbol;
2026
sample?: string | RegExp | object | Array<any> | Function;

0 commit comments

Comments
 (0)