Skip to content

Commit e519553

Browse files
committed
adding react-testing-lib
1 parent e533bea commit e519553

File tree

9 files changed

+204
-17
lines changed

9 files changed

+204
-17
lines changed

.eslintrc.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
"ecmaVersion": 2018,
99
"sourceType": "module"
1010
},
11-
"plugins": ["@typescript-eslint", "simple-import-sort"],
11+
"plugins": [
12+
"@typescript-eslint",
13+
"simple-import-sort"
14+
],
1215
"extends": [
1316
"prettier",
1417
"prettier/react",
@@ -40,4 +43,4 @@
4043
"browser": true,
4144
"es6": true
4245
}
43-
}
46+
}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# React (v16.8.0-alpha.0), Typescript, Yarn & Lerna Monorepo
1+
# React (v16.8.0+), Typescript, Yarn & Lerna Monorepo
22

3-
Starting point for a Typescript, React (v16.8.0-alpha.0), Yarn & Lerna monorepo project with full setup for ESLint and Prettier.
3+
Starting point for a Typescript, React (v16.8.0+, *tested up to v16.13.1*), Yarn & Lerna monorepo project with full setup for ESLint and Prettier.
44

55
## Stack
66

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
"clean": "lerna clean"
2222
},
2323
"devDependencies": {
24+
"@testing-library/jest-dom": "^5.7.0",
25+
"@testing-library/react": "^10.0.4",
26+
"@testing-library/user-event": "^10.1.1",
2427
"@types/jest": "^25.2.1",
2528
"@types/node": "^13.13.5",
2629
"@types/react": "^16.9.34",
@@ -43,4 +46,4 @@
4346
"packages/*"
4447
]
4548
}
46-
}
49+
}

packages/shared/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
"lint:fix": "eslint --fix . --ignore-path ../../.eslintignore --ext ts --ext tsx --ext js --ext jsx"
1717
},
1818
"peerDependencies": {
19-
"@types/jest": ">=24.0.0",
2019
"@types/node": ">=13.0.0",
2120
"@types/react": ">=16.8.0",
2221
"@types/react-dom": ">=16.8.0",

packages/www/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
"lint:fix": "eslint --fix . --ignore-path ../../.eslintignore --ext ts --ext tsx --ext js --ext jsx"
1717
},
1818
"peerDependencies": {
19+
"@testing-library/jest-dom": "^5.7.0",
20+
"@testing-library/react": "^10.0.4",
21+
"@testing-library/user-event": "^10.1.1",
1922
"@types/jest": ">=24.0.0",
2023
"@types/node": ">=13.0.0",
2124
"@types/react": ">=16.8.0",

packages/www/src/App.test.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
import { render } from '@testing-library/react';
12
import React from 'react';
2-
import ReactDOM from 'react-dom';
33

44
import App from './App';
55

6-
it('renders without crashing', () => {
7-
const div = document.createElement('div');
8-
ReactDOM.render(<App />, div);
9-
ReactDOM.unmountComponentAtNode(div);
6+
test('renders learn react link', () => {
7+
const { getByText } = render(<App />);
8+
const linkElement = getByText(/get more info on create react app/i);
9+
expect(linkElement).toBeInTheDocument();
1010
});

packages/www/src/App.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ const App = () => {
2222
Starting point for a Typescript, React, Yarn & Lerna monorepo project
2323
with full setup for ESLint and Prettier.
2424
</p>
25+
<a
26+
className="App-link"
27+
href="https://github.com/facebook/create-react-app"
28+
target="_blank"
29+
rel="noopener noreferrer"
30+
>
31+
Get more info on Create React App
32+
</a>
2533
</header>
2634
</div>
2735
);

packages/www/src/setupTests.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// jest-dom adds custom jest matchers for asserting on DOM nodes.
2+
// allows you to do things like:
3+
// expect(element).toHaveTextContent(/react/i)
4+
// learn more: https://github.com/testing-library/jest-dom
5+
import '@testing-library/jest-dom/extend-expect';

0 commit comments

Comments
 (0)