Skip to content

Commit

Permalink
Fix @testing-library/jest-dom types properly
Browse files Browse the repository at this point in the history
  • Loading branch information
karlhorky committed May 5, 2023
1 parent f98af47 commit 0c6a178
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"@types/testing-library__jest-dom": "5.14.5",
"eslint": "8.39.0",
"eslint-config-upleveled": "4.2.1",
"expect": "^29.5.0",
"stylelint": "^15.5.0",
"stylelint-config-upleveled": "^1.0.2",
"typescript": "5.0.4"
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/App.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ import App from './App';
test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
// @ts-ignore -- Getting proper types for @testing-library/jest-dom is not simple https://github.com/testing-library/jest-dom/issues/123#issuecomment-1536490617
expect(linkElement).toBeInTheDocument();
});
8 changes: 8 additions & 0 deletions src/react-app-env.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
/// <reference types="react-scripts" />
import { expect } from '@jest/globals';
import { TestingLibraryMatchers } from '@testing-library/jest-dom/matchers';

declare module 'expect' {
interface AsymmetricMatchers {}
interface Matchers<R = void>
extends TestingLibraryMatchers<typeof expect.stringContaining, R> {}
}
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"compilerOptions": {
"checkJs": true
},
"types": ["node", "jest", "@testing-library/jest-dom"],
"include": [
"**/.eslintrc.cjs",
"**/*.ts",
Expand Down

0 comments on commit 0c6a178

Please sign in to comment.