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 (no TODO tags) #2534

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,8 @@ packages/*/LICENSE.md
packages/enzyme/README.md
packages/enzyme-adapter-react-*/README.md
packages/enzyme-adapter-utils*/README.md

# vim
**/*.swp
*.swp

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
node_modules/.bin/mocha packages/enzyme-test-suite/build/ReactWrapper-spec.js
Copy link
Author

Choose a reason for hiding this comment

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

Incorporated tips provided by https://github.com/ljharb back into documentation.

```

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