Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New] add enzyme-adapter-react-17 #2430

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,15 @@ matrix:
- node_js: "lts/*"
env: LINT=true
stage: test
- node_js: "8"
env: REACT=17
stage: test
- node_js: "8"
env: REACT=16
stage: test
- node_js: "6"
env: REACT=17
stage: test
- node_js: "6"
env: REACT=16
stage: test
Expand Down Expand Up @@ -101,6 +107,7 @@ matrix:
- node_js: "6"
env: REACT=0.13
env:
- REACT=17.0
- REACT=16.14
- REACT=16.13
- REACT=16.12
Expand Down
3 changes: 3 additions & 0 deletions env.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ function getAdapter(reactVersion) {
return '16.1';
}
}
if (semver.intersects(reactVersion, '^17.0.0')) {
return '17';
}
return null;
}
const reactVersion = version < 15 ? '0.' + version : version;
Expand Down
4 changes: 4 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ function getPlugins() {
const adapter162 = new IgnorePlugin(/enzyme-adapter-react-16.2$/);
const adapter163 = new IgnorePlugin(/enzyme-adapter-react-16.3$/);
const adapter16 = new IgnorePlugin(/enzyme-adapter-react-16$/);
const adapter17 = new IgnorePlugin(/enzyme-adapter-react-17$/);

var plugins = [
adapter13,
adapter14,
adapter154,
adapter15,
adapter16,
adapter17,
];

function not(x) {
Expand All @@ -48,6 +50,8 @@ function getPlugins() {
plugins = plugins.filter(not(adapter163));
} else if (is('^16.4.0-0')) {
plugins = plugins.filter(not(adapter16));
} else if (is('^17.0.0')) {
plugins = plugins.filter(not(adapter17));
}

return plugins;
Expand Down
9 changes: 9 additions & 0 deletions packages/enzyme-adapter-react-17/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"presets": [
["airbnb", { "transformRuntime": false }],
],
"plugins": [
["transform-replace-object-assign", { "moduleSpecifier": "object.assign" }],
],
"sourceMaps": "both",
}
1 change: 1 addition & 0 deletions packages/enzyme-adapter-react-17/.eslintignore
22 changes: 22 additions & 0 deletions packages/enzyme-adapter-react-17/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"extends": "airbnb",
"parser": "babel-eslint",
"root": true,
"rules": {
"max-classes-per-file": 0,
"max-len": 0,
"import/no-extraneous-dependencies": 2,
"import/no-unresolved": 2,
"import/extensions": 2,
"react/no-deprecated": 0,
"react/no-find-dom-node": 0,
"react/no-multi-comp": 0,
"no-underscore-dangle": 0,
"class-methods-use-this": 0
},
"settings": {
"react": {
"version": "17",
},
},
}
1 change: 1 addition & 0 deletions packages/enzyme-adapter-react-17/.npmignore
1 change: 1 addition & 0 deletions packages/enzyme-adapter-react-17/.npmrc
74 changes: 74 additions & 0 deletions packages/enzyme-adapter-react-17/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"name": "enzyme-adapter-react-17",
"version": "0.0.0",
"description": "JavaScript Testing utilities for React",
"homepage": "https://enzymejs.github.io/enzyme/",
"main": "build",
"scripts": {
"clean": "rimraf build",
"lint": "eslint --ext js,jsx .",
"pretest": "npm run lint",
"prebuild": "npm run clean",
"build": "babel --source-maps=both src --out-dir build",
"watch": "npm run build -- -w",
"prepublish": "not-in-publish || (npm run build && safe-publish-latest && cp ../../{LICENSE,README}.md ./)"
},
"repository": {
"type": "git",
"url": "https://github.com/enzymejs/enzyme.git",
"directory": "packages/enzyme-adapter-react-17"
},
"keywords": [
"javascript",
"shallow rendering",
"shallowRender",
"test",
"reactjs",
"react",
"flux",
"testing",
"test utils",
"assertion helpers",
"tdd",
"mocha"
],
"author": "Jordan Harband <ljharb@gmail.com>",
"funding": {
"url": "https://github.com/sponsors/ljharb"
},
"license": "MIT",
"dependencies": {
"enzyme-adapter-utils": "^1.13.1",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even ^1.14.0 (which is currently latest) will throw peerDependency warnings due to requiring react 0.13.x || 0.14.x || ^15.0.0-0 || ^16.0.0-0.

enzyme-adapter-utils needs to have peerDependencies updated.
airbnb-prop-types needs to have peerDependencies updated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, that is a bit tricky, since airbnb-prop-types also uses enzyme to test itself, and it can't really claim to support React 17 unless it tests on it.

I'll be sure to update the peer deps for all the enzyme packages in this PR, though.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that needs to be much of a concern. react is only a peerDependency in airbnb-prop-types.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, which means that npm ls will fail when airbnb-prop-types and react 17 are installed, and npm 7+ will fail also.

"enzyme-shallow-equal": "^1.0.4",
"has": "^1.0.3",
"object.assign": "^4.1.0",
"object.values": "^1.1.1",
"prop-types": "^15.7.2",
"react-is": "^17.0.0",
"react-reconciler": "^0.26.1",
"react-test-renderer": "^17.0.0",
"semver": "^5.7.0"
},
"peerDependencies": {
"enzyme": "^3.0.0",
"react": "^17.0.0",
"react-dom": "^17.0.0"
},
"devDependencies": {
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"babel-eslint": "^10.1.0",
"babel-plugin-transform-replace-object-assign": "^2.0.0",
"babel-preset-airbnb": "^4.5.0",
"enzyme": "^3.0.0",
"eslint": "^7.6.0",
"eslint-config-airbnb": "^18.2.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-react": "^7.20.5",
"eslint-plugin-react-hooks": "^4.0.8",
"in-publish": "^2.0.1",
"rimraf": "^2.7.1",
"safe-publish-latest": "^1.1.4"
}
}
Loading
Loading