Skip to content

Commit 5110fde

Browse files
author
Kent C. Dodds
authored
Merge branch 'beta' into pr/update-node-engine
2 parents c87c782 + 9d0738f commit 5110fde

File tree

11 files changed

+136
-32
lines changed

11 files changed

+136
-32
lines changed

Diff for: .all-contributorsrc

+30-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
],
88
"imageSize": 100,
99
"commit": false,
10+
"skipCi": false,
1011
"contributors": [
1112
{
1213
"login": "kentcdodds",
@@ -1006,9 +1007,36 @@
10061007
"contributions": [
10071008
"doc"
10081009
]
1010+
},
1011+
{
1012+
"login": "zbrogz",
1013+
"name": "Zach Brogan",
1014+
"avatar_url": "https://avatars1.githubusercontent.com/u/319162?v=4",
1015+
"profile": "http://linkedin.com/in/zachbrogan",
1016+
"contributions": [
1017+
"code",
1018+
"test"
1019+
]
1020+
},
1021+
{
1022+
"login": "ryota-murakami",
1023+
"name": "Ryota Murakami",
1024+
"avatar_url": "https://avatars2.githubusercontent.com/u/5501268?v=4",
1025+
"profile": "https://ryota-murakami.github.io/",
1026+
"contributions": [
1027+
"doc"
1028+
]
1029+
},
1030+
{
1031+
"login": "hottmanmichael",
1032+
"name": "Michael Hottman",
1033+
"avatar_url": "https://avatars3.githubusercontent.com/u/10534502?v=4",
1034+
"profile": "https://github.com/hottmanmichael",
1035+
"contributions": [
1036+
"ideas"
1037+
]
10091038
}
10101039
],
10111040
"contributorsPerLine": 7,
1012-
"repoHost": "https://github.com",
1013-
"skipCi": true
1041+
"repoHost": "https://github.com"
10141042
}

Diff for: .github/ISSUE_TEMPLATE.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ Thanks for your interest in the project. We appreciate bugs filed and PRs submit
2020
2121
❓ Questions:
2222
For questions related to using the library, please visit a support community
23-
instead of filing an issue on GitHub.
23+
instead of filing an issue on GitHub. You can follow the instructions in this
24+
codesandbox to make a reproduction of your issue: https://kcd.im/rtl-help
2425
* React Spectrum
25-
https://spectrum.chat/react-testing-library
26+
https://spectrum.chat/testing-library
2627
* Reactiflux on Discord
2728
https://www.reactiflux.com
2829
* Stack Overflow
@@ -43,7 +44,7 @@ tutorial to learn how: http://kcd.im/pull-request
4344
4445
-->
4546

46-
- `react-testing-library` version:
47+
- `@testing-library/react` version:
4748
- `react` version:
4849
- `node` version:
4950
- `npm` (or `yarn`) version:

Diff for: .github/ISSUE_TEMPLATE/Bug_Report.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ tutorial to learn how: http://kcd.im/pull-request
2222
2323
-->
2424

25-
- `react-testing-library` version:
25+
- `@testing-library/react` version:
2626
- `react` version:
2727
- `node` version:
2828
- `npm` (or `yarn`) version:

Diff for: .github/ISSUE_TEMPLATE/Question.md

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ and feature requests so we recommend not using this medium to ask them here 😁
1212

1313
## ❓ Support Forums
1414

15+
For questions related to using the library, please visit a support community
16+
instead of filing an issue on GitHub. You can follow the instructions in this
17+
codesandbox to make a reproduction of your issue: https://kcd.im/rtl-help
18+
1519
- React Spectrum https://spectrum.chat/react-testing-library
1620
- Reactiflux on Discord https://www.reactiflux.com
1721
- Stack Overflow

Diff for: .travis.yml

+18-11
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
1-
sudo: false
21
language: node_js
3-
cache:
4-
directories:
5-
- ~/.npm
2+
cache: npm
63
notifications:
74
email: false
85
node_js:
9-
- '10'
10-
- '12'
11-
- '13'
6+
- 10.14
7+
- 12
8+
- node
129
install:
1310
- npm install
1411
# as requested by the React team :)
1512
# https://reactjs.org/blog/2019/10/22/react-release-channels.html#using-the-next-channel-for-integration-testing
16-
- if [ "$TRAVIS_EVENT_TYPE" = "cron" ]; then npm install react@next react-dom@next; fi
17-
script: npm run validate
18-
after_success: kcd-scripts travis-after-success
13+
- if [ "$TRAVIS_EVENT_TYPE" = "cron" ]; then npm install react@next
14+
react-dom@next; fi
15+
script:
16+
- npm run validate
17+
- npx codecov@3
1918
branches:
20-
only: master
19+
only:
20+
- master
21+
- beta
22+
23+
jobs:
24+
include:
25+
- stage: release
26+
node_js: 12
27+
script: kcd-scripts travis-release

Diff for: README.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export default HiddenMessage
171171
// __tests__/hidden-message.js
172172
// these imports are something you'd normally configure Jest to import for you
173173
// automatically. Learn more in the setup docs: https://testing-library.com/docs/react-testing-library/setup#cleanup
174-
import '@testing-library/jest-dom/extend-expect'
174+
import '@testing-library/jest-dom'
175175
// NOTE: jest-dom adds handy assertions to Jest and is recommended, but not required
176176

177177
import React from 'react'
@@ -261,7 +261,7 @@ export default Login
261261
// __tests__/login.js
262262
// again, these first two imports are something you'd normally handle in
263263
// your testing framework configuration rather than importing them in every file.
264-
import '@testing-library/jest-dom/extend-expect'
264+
import '@testing-library/jest-dom'
265265
import React from 'react'
266266
import {render, fireEvent, screen} from '@testing-library/react'
267267
import Login from '../login'
@@ -521,6 +521,11 @@ Thanks goes to these people ([emoji key][emojis]):
521521
<td align="center"><a href="http://www.laurensbosscher.nl"><img src="https://avatars0.githubusercontent.com/u/13363196?v=4" width="100px;" alt=""/><br /><sub><b>Laurens Bosscher</b></sub></a><br /><a href="https://github.com/testing-library/react-testing-library/commits?author=LaurensBosscher" title="Code">💻</a></td>
522522
<td align="center"><a href="https://twitter.com/__sakito__"><img src="https://avatars1.githubusercontent.com/u/15010907?v=4" width="100px;" alt=""/><br /><sub><b>Sakito Mukai</b></sub></a><br /><a href="https://github.com/testing-library/react-testing-library/commits?author=sakito21" title="Documentation">📖</a></td>
523523
<td align="center"><a href="http://turkerteke.com"><img src="https://avatars3.githubusercontent.com/u/12457162?v=4" width="100px;" alt=""/><br /><sub><b>Türker Teke</b></sub></a><br /><a href="https://github.com/testing-library/react-testing-library/commits?author=tteke" title="Documentation">📖</a></td>
524+
<td align="center"><a href="http://linkedin.com/in/zachbrogan"><img src="https://avatars1.githubusercontent.com/u/319162?v=4" width="100px;" alt=""/><br /><sub><b>Zach Brogan</b></sub></a><br /><a href="https://github.com/testing-library/react-testing-library/commits?author=zbrogz" title="Code">💻</a> <a href="https://github.com/testing-library/react-testing-library/commits?author=zbrogz" title="Tests">⚠️</a></td>
525+
</tr>
526+
<tr>
527+
<td align="center"><a href="https://ryota-murakami.github.io/"><img src="https://avatars2.githubusercontent.com/u/5501268?v=4" width="100px;" alt=""/><br /><sub><b>Ryota Murakami</b></sub></a><br /><a href="https://github.com/testing-library/react-testing-library/commits?author=ryota-murakami" title="Documentation">📖</a></td>
528+
<td align="center"><a href="https://github.com/hottmanmichael"><img src="https://avatars3.githubusercontent.com/u/10534502?v=4" width="100px;" alt=""/><br /><sub><b>Michael Hottman</b></sub></a><br /><a href="#ideas-hottmanmichael" title="Ideas, Planning, & Feedback">🤔</a></td>
524529
</tr>
525530
</table>
526531

Diff for: other/manual-releases.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ change is to release a new patch version.
4141
Reference: #<the number of a relevant pull request, issue, or commit>
4242
```
4343

44-
The number of times we've had to do a manual release is: 4
44+
The number of times we've had to do a manual release is: 5

Diff for: package.json

+8-7
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,19 @@
4545
"author": "Kent C. Dodds <[email protected]> (http://kentcdodds.com/)",
4646
"license": "MIT",
4747
"dependencies": {
48-
"@babel/runtime": "^7.8.3",
49-
"@testing-library/dom": "^6.11.0",
48+
"@babel/runtime": "^7.8.4",
49+
"@testing-library/dom": "beta",
5050
"@types/testing-library__react": "^9.1.2"
5151
},
5252
"devDependencies": {
53-
"@reach/router": "^1.2.1",
54-
"@testing-library/jest-dom": "^5.0.0",
55-
"cross-env": "^6.0.3",
56-
"kcd-scripts": "^4.0.0",
53+
"@reach/router": "^1.3.3",
54+
"@testing-library/jest-dom": "^5.1.1",
55+
"cross-env": "^7.0.1",
56+
"kcd-scripts": "^5.4.0",
5757
"npm-run-all": "^4.1.5",
5858
"react": "^16.9.0",
5959
"react-dom": "^16.9.0",
60-
"rimraf": "^3.0.0"
60+
"rimraf": "^3.0.2"
6161
},
6262
"peerDependencies": {
6363
"react": "*",
@@ -67,6 +67,7 @@
6767
"extends": "./node_modules/kcd-scripts/eslint.js",
6868
"rules": {
6969
"react/prop-types": "off",
70+
"react/no-adjacent-inline-elements": "off",
7071
"import/no-unassigned-import": "off",
7172
"import/named": "off"
7273
}

Diff for: src/__tests__/debug.js

+13
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,17 @@ test('debug pretty prints multiple containers', () => {
3636
)
3737
})
3838

39+
test('allows same arguments as prettyDOM', () => {
40+
const HelloWorld = () => <h1>Hello World</h1>
41+
const {debug, container} = render(<HelloWorld />)
42+
debug(container, 6, {highlight: false})
43+
expect(console.log).toHaveBeenCalledTimes(1)
44+
expect(console.log.mock.calls[0]).toMatchInlineSnapshot(`
45+
Array [
46+
"<div>
47+
...",
48+
]
49+
`)
50+
})
51+
3952
/* eslint no-console:0 */

Diff for: src/__tests__/events.js

+35
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,41 @@ eventTypes.forEach(({type, events, elementType, init}) => {
153153
})
154154
})
155155

156+
eventTypes.forEach(({type, events, elementType, init}) => {
157+
describe(`Native ${type} Events`, () => {
158+
events.forEach(eventName => {
159+
let nativeEventName = eventName.toLowerCase()
160+
161+
// The doubleClick synthetic event maps to the dblclick native event
162+
if (nativeEventName === 'doubleclick') {
163+
nativeEventName = 'dblclick'
164+
}
165+
166+
it(`triggers native ${nativeEventName}`, () => {
167+
const ref = React.createRef()
168+
const spy = jest.fn()
169+
const Element = elementType
170+
171+
const NativeEventElement = () => {
172+
React.useEffect(() => {
173+
const element = ref.current
174+
element.addEventListener(nativeEventName, spy)
175+
return () => {
176+
element.removeEventListener(nativeEventName, spy)
177+
}
178+
})
179+
return <Element ref={ref} />
180+
}
181+
182+
render(<NativeEventElement />)
183+
184+
fireEvent[eventName](ref.current, init)
185+
expect(spy).toHaveBeenCalledTimes(1)
186+
})
187+
})
188+
})
189+
})
190+
156191
test('onChange works', () => {
157192
const handleChange = jest.fn()
158193
const {

Diff for: src/pure.js

+15-5
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ function render(
6060
return {
6161
container,
6262
baseElement,
63-
debug: (el = baseElement) =>
63+
debug: (el = baseElement, maxLength, options) =>
6464
Array.isArray(el)
6565
? // eslint-disable-next-line no-console
66-
el.forEach(e => console.log(prettyDOM(e)))
66+
el.forEach(e => console.log(prettyDOM(e, maxLength, options)))
6767
: // eslint-disable-next-line no-console,
68-
console.log(prettyDOM(el)),
68+
console.log(prettyDOM(el, maxLength, options)),
6969
unmount: () => ReactDOM.unmountComponentAtNode(container),
7070
rerender: rerenderUi => {
7171
render(wrapUiIfNeeded(rerenderUi), {container, baseElement})
@@ -128,10 +128,20 @@ Object.keys(dtlFireEvent).forEach(key => {
128128
// React event system tracks native mouseOver/mouseOut events for
129129
// running onMouseEnter/onMouseLeave handlers
130130
// @link https://github.com/facebook/react/blob/b87aabdfe1b7461e7331abb3601d9e6bb27544bc/packages/react-dom/src/events/EnterLeaveEventPlugin.js#L24-L31
131-
fireEvent.mouseEnter = fireEvent.mouseOver
132-
fireEvent.mouseLeave = fireEvent.mouseOut
131+
const mouseEnter = fireEvent.mouseEnter
132+
const mouseLeave = fireEvent.mouseLeave
133+
fireEvent.mouseEnter = (...args) => {
134+
mouseEnter(...args)
135+
return fireEvent.mouseOver(...args)
136+
}
137+
fireEvent.mouseLeave = (...args) => {
138+
mouseLeave(...args)
139+
return fireEvent.mouseOut(...args)
140+
}
133141

142+
const select = fireEvent.select
134143
fireEvent.select = (node, init) => {
144+
select(node, init)
135145
// React tracks this event only on focused inputs
136146
node.focus()
137147

0 commit comments

Comments
 (0)