🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

react-test-renderer

Package Overview
Dependencies
Maintainers
11
Versions
2314
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-test-renderer - npm Package Compare versions

Comparing version

to
15.5.0-rc.1

lib/ReactShallowRenderer.js

9

lib/instantiateReactComponent.js

@@ -20,3 +20,3 @@ /**

var getNextDebugID = require('./getNextDebugID');
var getNextDebugID = require('react/lib/getNextDebugID');
var invariant = require('fbjs/lib/invariant');

@@ -29,5 +29,2 @@ var warning = require('fbjs/lib/warning');

};
_assign(ReactCompositeComponentWrapper.prototype, ReactCompositeComponent, {
_instantiateReactComponent: instantiateReactComponent
});

@@ -129,2 +126,6 @@ function getDeclarationErrorAddendum(owner) {

_assign(ReactCompositeComponentWrapper.prototype, ReactCompositeComponent, {
_instantiateReactComponent: instantiateReactComponent
});
module.exports = instantiateReactComponent;

@@ -517,3 +517,3 @@ /**

if (process.env.NODE_ENV !== 'production') {
this._checkContextTypes(Component.childContextTypes, childContext, 'childContext');
this._checkContextTypes(Component.childContextTypes, childContext, 'child context');
}

@@ -520,0 +520,0 @@ for (var name in childContext) {

@@ -181,5 +181,3 @@ /**

var lastMarkTimeStamp = 0;
var canUsePerformanceMeasure =
// $FlowFixMe https://github.com/facebook/flow/issues/2345
typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function';
var canUsePerformanceMeasure = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function';

@@ -186,0 +184,0 @@ function shouldMark(debugID) {

@@ -68,3 +68,2 @@ /**

var evt = document.createEvent('Event');
// $FlowFixMe https://github.com/facebook/flow/issues/2336
evt.initEvent(evtType, false, false);

@@ -71,0 +70,0 @@ fakeNode.dispatchEvent(evt);

@@ -349,3 +349,3 @@ /**

case HostComponent:
if (workInProgress.stateNode && config.beginUpdate) {
if (workInProgress.stateNode && typeof config.beginUpdate === 'function') {
config.beginUpdate(workInProgress.stateNode);

@@ -352,0 +352,0 @@ }

@@ -79,2 +79,4 @@ /**

ReactTestComponent.prototype.toJSON = function toJSON() {
// not using `children`, but I don't want to rewrite without destructuring
// eslint-disable-next-line no-unused-vars
var _currentElement$props = this._currentElement.props,

@@ -106,3 +108,6 @@ children = _currentElement$props.children,

ReactTestComponent.prototype.unmountComponent = function unmountComponent() {};
ReactTestComponent.prototype.unmountComponent = function unmountComponent(safely, skipLifecycle) {
// $FlowFixMe https://github.com/facebook/flow/issues/1805
this.unmountChildren(safely, skipLifecycle);
};

@@ -109,0 +114,0 @@ return ReactTestComponent;

@@ -171,3 +171,3 @@ /**

*/
enqueueReplaceState: function (publicInstance, completeState) {
enqueueReplaceState: function (publicInstance, completeState, callback) {
var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'replaceState');

@@ -182,2 +182,12 @@

// Future-proof 15.5
if (callback !== undefined && callback !== null) {
ReactUpdateQueue.validateCallback(callback, 'replaceState');
if (internalInstance._pendingCallbacks) {
internalInstance._pendingCallbacks.push(callback);
} else {
internalInstance._pendingCallbacks = [callback];
}
}
enqueueUpdate(internalInstance);

@@ -184,0 +194,0 @@ },

@@ -13,2 +13,2 @@ /**

module.exports = '15.4.2';
module.exports = '15.5.0-rc.1';
{
"name": "react-test-renderer",
"version": "15.4.2",
"version": "15.5.0-rc.1",
"description": "React package for snapshot testing.",

@@ -18,7 +18,7 @@ "main": "index.js",

"dependencies": {
"fbjs": "^0.8.4",
"fbjs": "^0.8.9",
"object-assign": "^4.1.0"
},
"peerDependencies": {
"react": "^15.4.2"
"react": "^15.5.0-rc.1"
},

@@ -30,4 +30,5 @@ "files": [

"index.js",
"shallow.js",
"lib/"
]
}
# `react-test-renderer`
This package provides an experimental React renderer that can be used to render React components to pure JavaScript objects, without depending on the DOM or a native mobile environment.
This package provides two React renderers that can be used for testing purposes:
Essentially, this package makes it easy to grab a snapshot of the "DOM tree" rendered by a React DOM or React Native component without using a browser or jsdom.
#### Test renderer
Usage:
Renders React components to pure JavaScript objects without depending on the DOM or a native mobile environment. This makes it easy to grab a snapshot of the "DOM tree" rendered by a React DOM or React Native component without using a browser or jsdom.

@@ -23,1 +23,21 @@ ```jsx

You can also use Jest's snapshot testing feature to automatically save a copy of the JSON tree to a file and check in your tests that it hasn't changed: http://facebook.github.io/jest/blog/2016/07/27/jest-14.html.
#### Shallow renderer
Shallow rendering lets you render a component "one level deep" and assert facts about what its render method returns, without worrying about the behavior of child components, which are not instantiated or rendered. This does not require a DOM.
```jsx
const ReactShallowRenderer = require('react-test-renderer/shallow');
const renderer = new ReactShallowRenderer();
renderer.render(<MyComponent />);
const result = renderer.getRenderOutput();
expect(result.type).toBe('div');
expect(result.props.children).toEqual([
<span className="heading">Title</span>,
<Subcomponent foo="bar" />
]);
```
This renderer was previously located in `react-addons-test-utils`.