Skip to content

Commit

Permalink
Merge branch 'master' into rodrigopr/cache-shallowed-wrapper-element
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigopr committed Feb 11, 2019
2 parents ae30cfd + f6689c5 commit b202023
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 10 deletions.
3 changes: 1 addition & 2 deletions docs/api/ReactWrapper/setState.md
Expand Up @@ -7,8 +7,7 @@ your component's external API (which is often accessible via [`.instance()`](ins
to get it into whatever state you want to test, in order to be as accurate of a test as possible.
This is not always practical, however.

NOTE: can only be called on a wrapper instance that is also the root instance.

NOTE: Prior to v3.8.0 of enzyme, can only be called on a wrapper instance that is also the root instance.

#### Arguments

Expand Down
4 changes: 2 additions & 2 deletions docs/guides/jest.md
Expand Up @@ -2,12 +2,12 @@

## Configure with Jest

To run the setup file to configure Enzyme and the Adapter (as shown in the [Installation docs](http://airbnb.io/enzyme/docs/installation/)) with Jest, set `setupTestFrameworkScriptFile` in your config file (check [Jest's documentation](http://jestjs.io/docs/en/configuration) for the possible locations of that config file) to literally the string `<rootDir>` and the path to your setup file.
To run the setup file to configure Enzyme and the Adapter (as shown in the [Installation docs](http://airbnb.io/enzyme/docs/installation/)) with Jest, set `setupFilesAfterEnv` (previously `setupTestFrameworkScriptFile`) in your config file (check [Jest's documentation](http://jestjs.io/docs/en/configuration) for the possible locations of that config file) to literally the string `<rootDir>` and the path to your setup file.

```json
{
"jest": {
"setupTestFrameworkScriptFile": "<rootDir>src/setupTests.js"
"setupFilesAfterEnv": ["<rootDir>src/setupTests.js"]
}
}
```
Expand Down
1 change: 0 additions & 1 deletion packages/enzyme-adapter-react-16.3/package.json
Expand Up @@ -35,7 +35,6 @@
"license": "MIT",
"dependencies": {
"enzyme-adapter-utils": "^1.10.0",
"function.prototype.name": "^1.1.0",
"object.assign": "^4.1.0",
"object.values": "^1.1.0",
"prop-types": "^15.6.2",
Expand Down
@@ -1,5 +1,4 @@
/* eslint no-use-before-define: 0 */
import functionName from 'function.prototype.name';
import React from 'react';
import ReactDOM from 'react-dom';
// eslint-disable-next-line import/no-unresolved
Expand Down Expand Up @@ -496,7 +495,7 @@ class ReactSixteenThreeAdapter extends EnzymeAdapter {
if (type.displayName) {
return type.displayName;
}
const name = type.render.displayName || functionName(type.render);
const name = displayNameOfNode({ type: type.render });
return name ? `ForwardRef(${name})` : 'ForwardRef';
}
default: return displayNameOfNode(node);
Expand Down
1 change: 0 additions & 1 deletion packages/enzyme-adapter-react-16/package.json
Expand Up @@ -35,7 +35,6 @@
"license": "MIT",
"dependencies": {
"enzyme-adapter-utils": "^1.10.0",
"function.prototype.name": "^1.1.0",
"object.assign": "^4.1.0",
"object.values": "^1.1.0",
"prop-types": "^15.6.2",
Expand Down
3 changes: 1 addition & 2 deletions packages/enzyme-adapter-react-16/src/ReactSixteenAdapter.js
@@ -1,5 +1,4 @@
/* eslint no-use-before-define: 0 */
import functionName from 'function.prototype.name';
import React from 'react';
import ReactDOM from 'react-dom';
// eslint-disable-next-line import/no-unresolved
Expand Down Expand Up @@ -550,7 +549,7 @@ class ReactSixteenAdapter extends EnzymeAdapter {
if (type.displayName) {
return type.displayName;
}
const name = type.render.displayName || functionName(type.render);
const name = displayNameOfNode({ type: type.render });
return name ? `ForwardRef(${name})` : 'ForwardRef';
}
default: return displayNameOfNode(node);
Expand Down
49 changes: 49 additions & 0 deletions packages/enzyme-test-suite/test/_helpers/react-compat.js
Expand Up @@ -6,6 +6,8 @@

import { is } from './version';

const { createFactory } = require('react');

let createClass;
let renderToString;
let createPortal;
Expand All @@ -21,6 +23,16 @@ let PureComponent;
let Suspense;
let lazy;
let memo;
let useCallback;
let useContext;
let useDebugValue;
let useEffect;
let useImperativeHandle;
let useLayoutEffect;
let useMemo;
let useReducer;
let useRef;
let useState;

if (is('>=15.5 || ^16.0.0-alpha || ^16.3.0-alpha')) {
// eslint-disable-next-line import/no-extraneous-dependencies
Expand Down Expand Up @@ -92,8 +104,35 @@ if (is('^16.6.0-0')) {
memo = null;
}

if (is('^16.8.0-0')) {
({
useCallback,
useContext,
useDebugValue,
useEffect,
useImperativeHandle,
useLayoutEffect,
useMemo,
useReducer,
useRef,
useState,
} = require('react'));
} else {
useCallback = null;
useContext = null;
useDebugValue = null;
useEffect = null;
useImperativeHandle = null;
useLayoutEffect = null;
useMemo = null;
useReducer = null;
useRef = null;
useState = null;
}

export {
createClass,
createFactory,
renderToString,
createPortal,
createContext,
Expand All @@ -108,4 +147,14 @@ export {
Suspense,
lazy,
memo,
useCallback,
useContext,
useDebugValue,
useEffect,
useImperativeHandle,
useLayoutEffect,
useMemo,
useReducer,
useRef,
useState,
};

0 comments on commit b202023

Please sign in to comment.