enzyme-shallow-equal
This is the implementation of shallowEqual that enzyme uses.
It's adapted from https://github.com/facebook/react/blob/144328fe81719e916b946e22660479e31561bb0b/packages/shared/shallowEqual.js#L36-L68
Adaptation of react-addons-shallow-compare, for independent usage
This is the implementation of shallowEqual that enzyme uses.
It's adapted from https://github.com/facebook/react/blob/144328fe81719e916b946e22660479e31561bb0b/packages/shared/shallowEqual.js#L36-L68
render
: handle Fiber strings and numbers (#2221)shallow
: Share child context logic between shallow
and dive
(#2296)mount
: children
: include text nodes ($2269)mount
: invoke
: use adapter’s wrapInvoke
if present (#2158)mount
/shallow
: closest
/parent
: Add missing arguments description (#2264)mount
/shallow
: fix pluralization of “exist” (#2262)shallow
/mount
: simulate
: added functional component example to simulate doc (#2248)mount
: debug
: add missing verbose option flag (#2184)mount
/shallow
: update
: fix semantics description (#2194)invoke
: Add missing backticks to end of codeblock (#2160)invoke
: Fix typo (#2167)funding
fieldis-boolean-object
, is-callable
, is-number-object
, is-string
, enzyme-shallow-equal
, array.prototype.flat
, function.prototype.name
, html-element-map
, is-regex
, object-inspect
, object-is
, object.entries
, object.vales
, raf
, string.prototype.trim
eslint
, eslint-plugin-import
, eslint-plugin-markdown
, eslint-plugin-react
, safe-publish-latest
, eslint-config-airbnb
, rimraf
, safe-publish-latest
, karma-firefox-launcher
, babel-preset-airbnb
, glob-gitignore
, semver
, eslint-plugin-jsx-a11y
shallow
add suspenseFallback
option; support Suspense
/Lazy
(#1975)shallow
/mount
: add invoke(propName)(...args)
(#1856, #945)shallow
: Support rendering and dive()
ing createContext()
providers and consumers (#1966)mount
/shallow
: add getWrappingComponent
(#1960)Utils
: add isCustomComponent
(#1960)Utils
: add stub
argument to spyMethod
EnzymeAdapter
: add matchesElementType
(#2146)RSTTraversal
: add getHTMLFromHostNodes
selectors
: unwrap memo
elements - in both directions (#2146)shallow
: properly determine "should render" for PureComponent
s (#2096)mount
/shallow
: renderProp
: improve error messages (#2070)mount
: setContext
: use proper wrapper name in error messageshallow
: .contains()
: clean up error messageshallow
/mount
: hasClass
: avoid a crash with a non-string argument (#2057)mount
: properly handle HTML of multiple nodes (#2052)shallow
: ensure that if gDSFP exists, cDU is called. (#2027)shallow
: Mock sCU if gDSFP defined in shallow renderer rerender (#1981)mount
: .state()
: allow getting state from stateful children of a stateless root (#2043)mount
: .text()
: properly recurse through fragments and arrays (#2028)ReactWrapper
/ShallowWrapper
: ensure calling an adapter‘s nodeToElement preserves the receivermount
: use getHTMLFromHostNodes
shallow
: fix childAt (#2134)debug
: Added documentation for verbose
flag (#2104)reduce
/reduceRight
: fix example code (#2066, #2065, #2064)simulateError
with getDerivedStateFromError
(#2036)shallow
: .hasClass
: fix use of mount
jest
: Update deprecated jest config key (#2024)shallow
: isEmptyRender
: allow on multiple elements (#1924)mount
: support :focus
selector (#1965)shallow
: Support getChildContext()
(#1971)shallow
/mount
: .find
: find HTML elements by their constructor (#1933)shallow
/mount
: selectors
: support universal selector (#1945)mount
/shallow
: add regex support to .hasClass
(#1987)mount
/shallow
: .text
/.html
: handle an array of nodes properly (#2001)shallow
: .setProps()
: only call cDU once (#2007)mount
: ensure findWhere
doesn‘t abort early on an empty string (#1995)mount
: findWhere
: avoid passing empty wrappers to predicatemount
: text()
via findWhere
: return the string for a wrapper around a stringmount
/shallow
: Fix .exists not accepting any EnzymeSelector (#1934)mount
: Recursive isEmptyRender
(#1924)mount
: setState
: allow setting state on a class child of an SFC rootsetupTestFrameworkScriptFile
to setupFilesAfterEnv
(#2013)mount
: setState
: note that you can now call it on "not the root" (#2010)isEmptyRender
, renderProp
, equals
, SystemJS guide (#1984, #1985)shallow
/mount
: add renderProp
(#1863, #1891)shallow
/mount
: improve error message for "single node" assertion (#1904)shallow
: shallow compare, not deep compare, state and props to determine rerendering (#1915)shallow
: dive
: add a note about throwing an error (#1905)selectors: update re
displayName` (#1932)shallow
: get
: fixed wrong props()
usage (#1921)shallow
: html
: shallow renders full tree (#1912)prop
: fix typo (#1883)mount
: ref
: use correct type (#1865)mount
: .state()
/.setState()
: allow calling on children (#1802, @ljharb)configuration
: add reset
(commit)makeOptions
: ensure that config-level attachTo
/hydrateIn
are inherited into wrapper options (#1836, @ljharb)shallow
/Utils
: call into adapter’s isCustomComponentElement
if present (#1832, @SinHouse)shallow
/mount
: throw an explicit error when state is null/undefined (commit)ROOT_NODES
for child wrappers (#1811, @jgzuke)shallow
: .parents
: ensure that one .find
call does not affect another (#1781, @ljharb)mount
: update after simulateError
(#1812, @jgzuke)mount
/shallow
: getElement
: use this.single
(commit)shallow
/mount
: add simulateError
(#1797, @ljharb)shallow
/mount
: containsMatchingElement
: trim whitespace (commit, #636)debug
: inspect objects instead of showing them as <Component />
(commit)mount
: ref
: Update docs to be consistent with v3 (#1242, @adam-golab)shallow
/mount
: make tests and method ordering more consistent (commit)adapter
truthiness check (commit)shallow
: prevent rerenders with PureComponents (#1786, @koba04)shallow
: skip updates when nextState is null
or undefined
(#1785, @koba04)shallow
: setState
after setProps
calls componentWillReceiveProps
(#1779, @peanutenthusiast)mount
/shallow
: be stricter on the wrapper’s setState/setProps callback (commit)shallow
/mount
: improve error message when wrapping invalid elements (#1759, @jgzuke)shallow
: fix unexpected call to componentDidMount (#1768)shallow
: .setState()
: stub out setState
on non-root code paths as well (#1763)shallow
/mount
: restore fallback when adapter lacks invokeSetStateCallback
(commit)mount
: setState
: invoke callback with the proper receiver (commit)mount
: state
and setState
should throw an explicit error message when called on an SFC (commit)shallow
: call cDU when an instance calls setState (#1742)selectors
: fix descendant selector (#1680)shallow
: setProps
: merge instead of replace props (commit)shallow
/mount
: account for React.Fragment nodes (#1733)debugNode
now returns [function]
for function children (commit)mount
: add hydrateIn
option (#1707)shallow
: add “lifecycles” adapter option (#1696)shallow
/mount
: allow .exists()
to take an optional selector (#1695)shallow
: Add getSnapshotBeforeUpdate support (#1657)shallow
/mount
: Add support for some pseudo selectors (#1537)debug
: Implement verbose debug output (#1547)Debug
: typeName
now calls the adapter’s displayNameOfNode
if available (#1701)mount
/shallow
: .name()
: call into adapter’s displayNameOfNode
, if present (#1701)Utils
: nodeHasType
: call into adapter’s displayNameOfNode
, if present (#1701)selectors
: buildPredicate
: call into adapter’s isValidElementType
, if present (#1701)shallow
: setProps()
: Add callback argument (#1721)mount
: add .equals()
(commit)getAdapter
from Utils
into its own file (#1732)shallow
/mount
: matchesElement
/containsMatchingElement
: get adapter with options (commit)RSTTraversal
: remove nodeHasProperty
export; broken since #1157 (commit)shallow
: .at()
: return an empty wrapper when an index does not exist (#1478)shallow
: .equals()
: flatten children when comparing (commit)mount
/shallow
: do not dedupe in flatMap (commit)shallow
: .closest()
: ensure an empty wrapper is returned for no match (commit)selectors
: make general sibling not throw on root (#1698)mount
: text()
: null nodes return null (#1582)shallow
: simulate
: ensure it returns itself (commit)shallow
: ShallowWrapper calls update() automatically (#1499)mount
/shallow
: return null for missing keys (#1536)setState
callback after finishing the render (#1453)shallow
/mount
: default iterator should be iterable (commit)selectors
: fix typos; avoid reusing variable unnecessarily (#1681)shallow
: Use spyMethod
to inspect the result of shouldComponentUpdate
/getSnapshotBeforeUpdate
(#1192)Utils
: configuration
: change to named exports. (commit)array.prototype.flat
(commit)ref(refName)
(#1470)shallow
/mount
: Add callback arg to setProps header (#1361)mount
: Updated docs for ReactWrapper.instance(); remove docs for v2's getNode()
/getNodes()
(#1714)debug
: handle boxed primitives (#1450)@lelandrichardson: Add an npmignore file to all packages (#1204)
@neoziro: Fix node resolving in React 16 adapter (#100)
@graingert: upgrade to rst-selector-parser@^2.2.2 (#1146)
@lelandrichardson: Symlink readme to all packages (#1205)
@AndersDJohnson: fix some typos (#1165)
@dubbha: ES5 setup file correction (#1194)
@morrowr08: updated component name being used in example (#1180)
@apandichi: Fixing a few typos... (#1171)
@nuc: Fix typo (#1142)
Enzyme has several breaking changes from v2 to v3. Please check out our migration guide for more info. Since there was a rewrite of the core library from v2 to v3, it is hard to categorize changes in terms of sem
@lelandrichardson: Refactor enzyme to use Adapters, initial React 16 support (#1007)
@lelandrichardson: Make private properties more private and harder to use (#1083)
@ljharb: [breaking] update cheerio
to v1 (#1093)
@aweary: Integrate with a CSS parser for selector parsing (#1086)
@vadimdemedes: Skip undefined props when comparing nodes (#662)
@koba04: Breaking: lifecycleExperimental by default (#1140)
@lelandrichardson: Move to lerna repo structure, multiple modules (#1074)
@lelandrichardson: Remove all React dependencies from enzyme (#1084)
@lelandrichardson: Add public root method (#1127)
@aweary: Remove isFunctionalComponent, use nodeType instead (#1076)
@LarsHassler: props not merged when shallow rendering in lifecycleExperimental (#1088)
@ljharb: [Fix] mount
: do not mutate Component.contextTypes
(#1099)
@ljharb: [Fix] reduce
/reduceRight
: follow Array#reduce
when omitting initialValue (#673)
@koba04: Fix componentDidUpdate when updating by setState on v16 (#1133)
@koba04: Fix componentDidUpdate no longer receives prevContext on React v16 (#1139)
@ghost: added sinon to mocha guide (#1075)
@samit4me: Update to GitBook 3 (#1039)
@therewillbecode: Removed extraneous brackets from example in readme (#1117)
@silvenon: Add note that mount() requires cleanup (#1043)
@lelandrichardson: Add docs reflecting v3 (#1121)
mount
/shallow
: debug
: add ignoreProps
option (#960)shallow
: debug: fix indentation (#926)nvm
install instructions (never install it with homebrew) (#988)shallow
/mount
: Make all references to the wrapper class
call into this.wrap
uuid
from v2 to v3 (#998)React.createClass
(#877)false
and lifecycleExperimental
is on (#807)dive
(#771)ShallowWrapper#dive()
(#759shallow
/mount
: Add .slice()
method (#661)mount
: implement ReactWrapper#getDOMNode (#679)shallow
/mount
: Add exists
; deprecate isEmpty() (#722)mount
: extract MountedTraversal.hasClassName from MountedTraversal.instHasClassName, which allows ReactWrapper.hasClass to bypass the !isDOMComponent(inst) call (#677)withDom
: Display a useful error when withDom
fails to find "jsdom" (#686)mount
: ensure that react-text
comment nodes don’t break .find
(#691)mount
: .parents()
now filters out sibling path trees (#713)single
(#632)pass callback on setState and setProps (#617)
Make ReactWrapper and ShallowWrapper iterable (#594)
add .dive()
method to shallow
(#618)
Warn if selector contains a pseudo-class (#591)
change isCompoundSelector to not match prop selector (#595)
fixed hasClassName in case className is not a string and has toString method (#518)
Throw if some() is called on a root wrapper (#523)
Fix valid + falsy propvalues (#563)
shouldComponentUpdate
call (#491)Support all Component Lifecycle methods in ShallowRenderer (behind an experimental flag) (#318)
Add an isEmptyRender()
method to both ShallowWrapper
and ReactWrapper
(#339)
Add support for batched updates with ShallowRender.simulate
(#342)
Switch to using classList instead of className (#448)
fixes mount().debug() output with mixed children (#476)
Support additional characters in attribute selectors (#412)
fix id selector not working when combined with a tag selector (#387)
Support spaces in attribute selector values (#427)
add .tap()
method to ShallowWrapper
and ReactWrapper
(#299)
add .key()
method to ShallowWrapper
and ReactWrapper
(#327)
add support for descendent selectors, >
, ~
and +
(#217)
new containsMatchingElement
, containsAllMatchingElements
, and containsAnyMatchingElements
APIs (#362)
new .name()
method (#335)
add dblclick
to eventType map for simulate (#317)
fix pathToNode
bug with child-containing children (#296)
prioritize displayName
over name
for consistency in .debug()
(#332)
handle insignificant whitespace in className (#348)
fix handling of SFC components and .instance()
(#359)
reduce false positives by using argument validation for .contains
(#259)
fix equality algorithm so that non-renderable nodes are equivalent (#192)
add better error handling for state
, setState
, and context
(#373)
options
param to ShallowWrapper::shallow
(#275)make enzyme compatible with all React 15 RCs (#272)
increase coverage for Stateless Functional Components (#267)
improve context support for Stateless Functional Components (#256)
fix tree traversal for Stateless Functional Components (#257)
fix .find
for nested Stateless Functional Components (#274)
fix .props()
and .debug()
methods for Stateless Functional Components (#255)
prevent falsy nodes from being counted as children (#251)
add support for React 15.0.0-rc.1 (#240)
add .unmount()
method for ShallowWrapper (#215)
add direct imports for mount
, shallow
, and render
(#198)
add a .childAt(n)
shorthand method (#187)
fix bug in .contains() for matching sub-arrays (#226)
fix bug in matching by type displayName (#230)
add more useful warnings for missing implicit dependencies (#228)
improve SFC support for .type()
(#196)
fix null handling for .html()
and .render()
(#196)
moved from underscore
to lodash
(#189)
removed describeWithDOM
utility (#159)
removed useSinon
, spyPrototype
and spyLifecycle
utilities (#159)
removed sinon
dependency (#159)
removed jsdom
dependency (#159)
ReactWrapper
(#171)Prevent null or false nodes from being passed into tree traversal (#174)
setProps no longer swallows exceptions (#170)
.type()
and .props()
should not fail on null now (#162)
Add attachTo
option to mount
to mount to a specific element (#160)
Add .debug()
method to ReactWrapper
(#158)
Add .mount()
and .unmount()
APIs to ReactWrapper
(#155)
Add .render()
method to ReactWrapper
(#156)
Allow .contains()
to accept an array of nodes (#154)
Add .context()
method to ReactWrapper
and ShallowWrapper
(#152)
Fixed some behavior with .contains()
matching on strings (#148)
Fixed .debug()
's output for numeric children (#149)
Documentation fixes
Update versions of dependencies
describeWithDOM
enhancement (#126)
add .equals()
method to ShallowWrapper
(#124)
add object selector syntax (#110)
Fixed confusing behavior of prop selector syntax (#130)
Documentation fixes
Added .html()
method to ReactWrapper
(#71)
Support property selector (i.e. [prop="foo"]
) (#70)
jsdom dependency now allows a range of supported versions (#95)
Normalized setProps()
behavior between mount
/shallow
to merge props (#103)
Exclude _book
from published package (#85)
Various documentation, tests, and style changes
nodeHasId
fix for some 0.14 corner cases (#65)describeWithDOM
messaging (#48)