Skip to content

Commit 218e4f7

Browse files
JC LeeAndarist
JC Lee
andauthored
Add RegExp as a valid type for the target option accepted by toHaveStyleRule (#2457)
* add RegExp as typing for target - With typescript in place, the typing that only allows string will not be able to receive a RegExp. Being able to receive a RegExp will allow target options describe in [this issue](#1875) * Create sweet-planes-begin.md * Update packages/jest/types/index.d.ts Co-authored-by: Mateusz Burzyński <[email protected]>
1 parent eda5e68 commit 218e4f7

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

.changeset/sweet-planes-begin.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@emotion/jest": patch
3+
---
4+
5+
Add `RegExp` as a valid type for the `target` option accepted by `toHaveStyleRule`.

packages/jest/src/matchers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function toHaveStyleRule(
4343
received: *,
4444
property: *,
4545
value: *,
46-
options?: { target?: string, media?: string } = {}
46+
options?: { target?: string | RegExp, media?: string } = {}
4747
) {
4848
const { target, media } = options
4949
const classNames = getClassNamesFromNodes([received])

packages/jest/types/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ type SnapshotSerializerPlugin = Extract<
99
>
1010

1111
export interface StyleRuleOptions {
12-
target?: string
12+
target?: string | RegExp
1313
media?: string
1414
}
1515

0 commit comments

Comments
 (0)