Skip to content

Commit

Permalink
Add @testing-library/jest-dom
Browse files Browse the repository at this point in the history
  • Loading branch information
ehyland committed Sep 5, 2022
1 parent 5d5e021 commit 1691b03
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 0 deletions.
1 change: 1 addition & 0 deletions react-ts-webpack-babel/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @type {import('@jest/types').Config.InitialOptions} */
module.exports = {
testEnvironment: 'jsdom',
setupFilesAfterEnv: ['<rootDir>/src/test-utils/jest/setup.ts'],
moduleDirectories: ['node_modules', 'src'],
transform: {
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|css)$':
Expand Down
2 changes: 2 additions & 0 deletions react-ts-webpack-babel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
"@babel/preset-typescript": "^7.18.6",
"@babel/runtime": "^7.18.9",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.7",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.3.0",
"@types/jest": "^28.1.7",
"@types/react": "^18.0.17",
"@types/react-dom": "^18.0.6",
"@types/testing-library__jest-dom": "^5.14.5",
"babel-loader": "^8.2.5",
"clsx": "^1.2.1",
"css-loader": "^6.7.1",
Expand Down
66 changes: 66 additions & 0 deletions react-ts-webpack-babel/pnpm-lock.yaml

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

4 changes: 4 additions & 0 deletions react-ts-webpack-babel/src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ describe('<App />', () => {
render(<App />);
});

it('renders the date node', () => {
expect(screen.getByTestId('date')).toBeInTheDocument();
});

it('renders the date', () => {
expect(screen.getByTestId('date').textContent).toEqual(
'2022-09-04T02:00:00.000Z'
Expand Down
1 change: 1 addition & 0 deletions react-ts-webpack-babel/src/test-utils/jest/setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '@testing-library/jest-dom';

0 comments on commit 1691b03

Please sign in to comment.