diff --git a/.changeset/sweet-planes-begin.md b/.changeset/sweet-planes-begin.md new file mode 100644 index 0000000000..8161c19534 --- /dev/null +++ b/.changeset/sweet-planes-begin.md @@ -0,0 +1,5 @@ +--- +"@emotion/jest": patch +--- + +Add `RegExp` as a valid type for the `target` option accepted by `toHaveStyleRule`. diff --git a/packages/jest/src/matchers.js b/packages/jest/src/matchers.js index 60fcf08781..f426c6d7eb 100644 --- a/packages/jest/src/matchers.js +++ b/packages/jest/src/matchers.js @@ -43,7 +43,7 @@ function toHaveStyleRule( received: *, property: *, value: *, - options?: { target?: string, media?: string } = {} + options?: { target?: string | RegExp, media?: string } = {} ) { const { target, media } = options const classNames = getClassNamesFromNodes([received]) diff --git a/packages/jest/types/index.d.ts b/packages/jest/types/index.d.ts index f0b21ddb91..0eaab6bd41 100644 --- a/packages/jest/types/index.d.ts +++ b/packages/jest/types/index.d.ts @@ -9,7 +9,7 @@ type SnapshotSerializerPlugin = Extract< > export interface StyleRuleOptions { - target?: string + target?: string | RegExp media?: string }