Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

feat: add testing-library expect matchers #12

Merged
merged 1 commit into from
Feb 17, 2022
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"dependencies": {
"@storybook/expect": "storybook-jest",
"@storybook/instrumenter": "6.4.0-rc.5",
"@testing-library/jest-dom": "^5.16.2",
"jest-mock": "^27.3.0"
},
"devDependencies": {
Expand Down
11 changes: 8 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { default as expectPatched } from '@storybook/expect';
import { instrument } from '@storybook/instrumenter';
import * as matchers from '@testing-library/jest-dom/matchers';
import * as mock from 'jest-mock';

export const { jest } = instrument({ jest: mock });
const { jest } = instrument({ jest: mock });

export const expect: typeof expectPatched = instrument(
const expect: typeof expectPatched = instrument(
{ expect: expectPatched },
{ intercept: (method, path) => path[0] !== 'expect' }
{ intercept: (_method, path) => path[0] !== 'expect' }
).expect;

expect.extend(matchers);

export { expect, jest };
1 change: 1 addition & 0 deletions src/typings.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module '@testing-library/jest-dom/matchers';