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

add enzyme-adapter-react-17 #2564

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e91c355
[New] add `enzyme-adapter-react-17`
ljharb Aug 10, 2020
0797375
feat: add an adapter for React 17
layershifter Aug 12, 2020
42fce4a
add versions to CI
layershifter Aug 12, 2020
46de537
version updates
layershifter Aug 12, 2020
13111be
offscreencomponent wip
ljharb Oct 26, 2020
1337f75
test TODOs
ljharb Jan 20, 2021
07504db
Remove TODO_17 tags
createthis Aug 10, 2021
75a15f4
Fix two failing tests by using less fragile syntax.
createthis Aug 10, 2021
658595a
Fix another test with fragile matching.
createthis Aug 10, 2021
9625c9f
componentWillReceiveProps and UNSAFE_componentWillReceiveProps removed
createthis Aug 10, 2021
7a54423
Fix shallow() so that it calls componentWillReceiveProps() and
createthis Aug 11, 2021
938d10a
Forgot a test case. Call componentWillReceiveProps() even when shallow
createthis Aug 11, 2021
bbab94b
displayNameOfNode gets a little wonky when used with React.memo and
createthis Aug 11, 2021
9a432a6
punt on the simulate failure. I worked on this all day yesterday and
createthis Aug 13, 2021
1f48ca9
Make a few changes I saw https://github.com/wojtekmaj requested in the
createthis Aug 13, 2021
ae9b14a
Add tip from https://github.com/ljharb to CONTRIBUTING
createthis Aug 13, 2021
935c84a
Restore suspense tests to the best of my ability.
createthis Aug 13, 2021
18d536f
createReactClass and React.Component pass the same check
eps1lon Aug 2, 2022
69f2846
Remove unused TODO_17
eps1lon Aug 2, 2022
5f2f0b1
Adjust displayname test to be invariant across React versions
eps1lon Aug 2, 2022
9dfd35f
Fix displayNameOfNode for Memo components
eps1lon Aug 2, 2022
cc64090
Fix isEmptyRender for SimpleMemoComponent
eps1lon Aug 3, 2022
762ac8c
Ensure Suspense tests are the same in 16 and 17
eps1lon Aug 3, 2022
cffae58
Remove React 16 logic that is no longer covered by tests
eps1lon Aug 3, 2022
7f309a1
Remove no obsolete "supports*" checks when detecting Fiber tags
eps1lon Aug 3, 2022
3b9b1e3
node_modules/.bin -> npx
eps1lon Aug 9, 2022
103174d
Revert .gitignore changes from base branch
eps1lon Aug 9, 2022
5418b9d
Remove outdated comment
eps1lon Aug 9, 2022
8649c0c
Simplify semver matcher for create-react-class
eps1lon Aug 9, 2022
8712dca
Merge branch 'master' into feat/support-react17-sebbie
eps1lon Oct 27, 2022
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 @@ -39,9 +39,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 @@ -112,6 +118,7 @@ matrix:
- node_js: "6"
env: REACT=0.13
env:
- REACT=17.0
- REACT=16.14
- REACT=16.13
- REACT=16.12
Expand Down
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,19 @@ npm run build:watch
npm run test:watch
```

Alternatively, run this in one terminal tab:
```bash
# build Enzyme locally upon save
npm run build:watch
```

In another terminal tab execute a specific test file for faster TDD test execution:
```bash
npx mocha packages/enzyme-test-suite/build/ReactWrapper-spec.js
```

NOTE that this alternate strategy may fail to rebuild some code and will bypass lint, so `npm test` will still be necessary periodically.

### Tests for functionality shared between `shallow` and `mount`

Tests for a method "foo" are stored in `packages/enzyme-test-suite/test/shared/methods/foo`. The file default exports a function that receives an injected object argument, containing the following properties:
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 <[email protected]>",
"funding": {
"url": "https://github.com/sponsors/ljharb"
},
"license": "MIT",
"dependencies": {
"enzyme-adapter-utils": "^1.13.1",
"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