Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/sweet-planes-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@emotion/jest": patch
---

Add `RegExp` as a valid type for the `target` option accepted by `toHaveStyleRule`.
2 changes: 1 addition & 1 deletion packages/jest/src/matchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function toHaveStyleRule(
received: *,
property: *,
value: *,
options?: { target?: string, media?: string } = {}
options?: { target?: string | RegExp, media?: string } = {}
Copy link
Member

Choose a reason for hiding this comment

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

I suspect that you might have wanted to fix in the TS types which are, currently, located here:

target?: string

You have only changed the Flow type here - and we are in the process of replacing Flow with TS.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changes made!

) {
const { target, media } = options
const classNames = getClassNamesFromNodes([received])
Expand Down
2 changes: 1 addition & 1 deletion packages/jest/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type SnapshotSerializerPlugin = Extract<
>

export interface StyleRuleOptions {
target?: string
target?: string | RegExp
media?: string
}

Expand Down