Improvements
react-drill/lib/Scope.js
.m
exported symbol)
using the drill.registerMatcher interface.Bugfixes
Fixed an issue with component selectors (e.g. Selectors.findComponentByType) that would incorrectly locate components whose DOM nodes are not necessarily descendants of the Scope's current DOM nodes.
There's a chance this may have caused some false positives in your tests - sorry!
Breaking changes
React.Component
classes now have the default name of Component
instead of ReactComponent
. If you have tests that rely on this default,
make sure you update those as they could be broken.The following functions were dropped from the Scope object because they were confusing and didn't add any value by themselves:
Scope#findAllByType
Scope#findBySelector
Scope#findByType
Scope#findComponentByType
In their place, one can now use Scope#find for locating a single element and Scope#findAll for locating multiple ones. Both APIs accept either a DOM query or a React class as a selector and the return type has been adjusted accordingly.
Potentially breaking changes (actions)
The following changes are made with the intent of getting closer to simulating exactly how React would trigger interactions when used in the browser by a real user.
Actions.click no longer accepts a simulateNative
option. A new action
has been introduced that dispatches a native browser event to use if needed:
Actions.clickNative.
Actions.check no longer accepts an isChecked
boolean option. If you
want to uncheck a checkbox, use the new action Actions.uncheck instead.
Actions.select no longer directly sets the value
property of the
<select />
node.
Actions.typeIn no longer accepts the dontReplace
boolean option and no
longer truncates the target's "value" property by default. If you are relying
on this functionality, consider calling .fillIn('')
on the scope first.
Actions.paste no longer manually fills in the target's "value" property
with the text. Instead, it creates a proper
ClipboardEvent with the textual content specified in the
clipboardEvent
properties data field (type text
.) If you are relying on
the previous behavior, consider calling .fillIn(text)
on the scope first.
Please note that this only works on Chrome right now since it's the only
browser that currently supports instantiating DataTransfer
objects. For
other browsers we fall back to the previous behavior.
Actions.typeIn no longer implicitly focuses the target nor does it fill in the target's "value" property with the text. Instead, it triggers events for each character as React would in the browser if the user were to type. The sequence of events is:
keyDown
keyPress
beforeInput
input
change
keyUp
Actions.keyPress, Actions.keyDown, and Actions.keyUp no longer
focus the target implicitly. If you are relying on this functionality,
consider calling .focus()
on the scope before the call to any of them.
Deprecations
The following symbols that were exported from the main package have been renamed. The previous symbols are still around but will trigger a deprecation notice and will be removed in a future release:
Scope.registerHTMLElementMethod
-> drill.registerActionDOMHelpers
-> ActionsDOMSelectors
-> SelectorsPlease consult the upgrade guide for guidance.
Other notes
React.createClass()
is still supported by Drill, but note that if you are
upgrading your own codebase to React 16 it will not be supported there. It is
recommended to migrate your components to ES6 classes, but you can also use
the create-react-class
package as a drop-in replacement.create-react-class
, make sure you label the import as
createReactClass
, otherwise Drill will have issues tracing your
components displayName's, which could potentially cause false negatives in
your tests.react-addons-test-utils
package since it's now in 'react-dom'#find
with HTMLElement or SVGElement in IE11react-addons-test-utils
package since it's no longer provided by react
react
and react-dom
as peer dependencies instead of dependencies.DOMSelectors.find
would throw an exceptionfindDOMNode
and scryRenderedComponentsWithType
routines other than ReactDOM for non-DOM React environments.dispatchNativeEvent
DOM helper#find()
and other DOMSelectors from finding objects inside an iframe.contentWindow
drill
will now forward the second argument to Scope
; the nodesInternal changes:
DOMHelpers
into a separate module, DOMSelectors
check
, keyPress
, and paste
has(t: String|React.Class, cond: Function) -> bool
find()
from properly matching a node in a selectionhasAttribute(name: String, value: String) -> bool
end()
method to the drilling API/dist
) in git, only in the npm package