react-test-wrapper
Advanced tools
Comparing version 2.1.1 to 3.0.0
@@ -6,6 +6,7 @@ { | ||
"license": "ISC", | ||
"version": "2.1.1", | ||
"version": "3.0.0", | ||
"keywords": [ | ||
"component", | ||
"enzyme", | ||
"react-testing-library", | ||
"jest", | ||
@@ -32,5 +33,5 @@ "react", | ||
"lint:fix": "eslint \"./src/**/*.ts?(x)\" --fix", | ||
"test": "cross-env NODE_ENV=test jest --no-cache --config ./jest.config.js", | ||
"test": "cross-env NODE_ENV=test jest --no-cache --runInBand --config ./jest.config.js", | ||
"test:all": "npm-run-all format typecheck lint:fix test:coverage", | ||
"test:coverage": "cross-env NODE_ENV=test jest --no-cache --coverage --config ./jest.config.js", | ||
"test:coverage": "cross-env NODE_ENV=test jest --no-cache --runInBand --coverage --config ./jest.config.js", | ||
"typecheck": "tsc" | ||
@@ -49,2 +50,3 @@ }, | ||
"peerDependencies": { | ||
"@testing-library/react": ">= 12.0.0", | ||
"enzyme": ">= 3.11.0", | ||
@@ -57,2 +59,5 @@ "react": ">= 17.0.2", | ||
"peerDependenciesMeta": { | ||
"enzyme": { | ||
"optional": true | ||
}, | ||
"react-intl": { | ||
@@ -64,2 +69,5 @@ "optional": true | ||
}, | ||
"@testing-library/react": { | ||
"optional": true | ||
}, | ||
"redux": { | ||
@@ -70,29 +78,31 @@ "optional": true | ||
"devDependencies": { | ||
"@types/enzyme": "^3.10.8", | ||
"@types/jest": "^26.0.23", | ||
"@types/react": "^17.0.5", | ||
"@types/react-redux": "^7.1.16", | ||
"@typescript-eslint/eslint-plugin": "^4.23.0", | ||
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.1", | ||
"@testing-library/react": "^12.0.0", | ||
"@types/enzyme": "^3.10.9", | ||
"@types/jest": "^26.0.24", | ||
"@types/react": "^17.0.14", | ||
"@types/react-redux": "^7.1.17", | ||
"@typescript-eslint/eslint-plugin": "^4.28.2", | ||
"@typescript-eslint/parser": "^4.28.2", | ||
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.2", | ||
"cross-env": "^7.0.3", | ||
"enzyme": "^3.11.0", | ||
"enzyme-to-json": "^3.6.2", | ||
"eslint": "^7.26.0", | ||
"eslint": "^7.30.0", | ||
"eslint-config-voodoocreation": "^2.0.1", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-import": "^2.23.4", | ||
"eslint-plugin-jest": "^24.3.6", | ||
"eslint-plugin-jsx-a11y": "^6.4.1", | ||
"eslint-plugin-prefer-arrow": "^1.2.3", | ||
"eslint-plugin-react": "^7.23.2", | ||
"eslint-plugin-react": "^7.24.0", | ||
"eslint-plugin-react-hooks": "^4.2.0", | ||
"jest": "^26.6.3", | ||
"jest": "^27.0.6", | ||
"npm-run-all": "^4.1.5", | ||
"prettier": "^2.3.0", | ||
"prettier": "^2.3.2", | ||
"react": "^17.0.2", | ||
"react-dom": "^17.0.2", | ||
"react-intl": "^5.17.5", | ||
"react-intl": "^5.20.4", | ||
"react-redux": "^7.2.4", | ||
"redux": "^4.1.0", | ||
"ts-jest": "^26.5.6", | ||
"typescript": "^4.2.4", | ||
"ts-jest": "^27.0.3", | ||
"typescript": "^4.3.5", | ||
"typescript-fsa": "^3.0.0", | ||
@@ -99,0 +109,0 @@ "typescript-fsa-reducers": "^1.2.2" |
@@ -15,3 +15,4 @@ React Test Wrapper | ||
the single instance and define the scenario-specific props/children etc. chaining the public methods, | ||
then finally calling the `mount`, `shallow` or `render` method to return the Enzyme wrapper and merged props. | ||
then finally calling the `mount`, `shallow` or `render` method (only `render` is available in the | ||
`react-testing-library` variants) to return the rendering result. | ||
@@ -22,3 +23,4 @@ The scenario-specific definitions are reset each time you call `mount`, `render` or `shallow`, which | ||
For example: | ||
## Example | ||
### With `enzyme` | ||
```typescript jsx | ||
@@ -49,8 +51,34 @@ const component = new Wrapper(SomeComponent) | ||
### With `react-testing-library` | ||
```typescript jsx | ||
const component = new Wrapper(SomeComponent) | ||
.withDefaultChildren(<div className="Child" />) | ||
.withDefaultProps({ | ||
prop1: "Default value 1", | ||
prop2: "Default value 2" | ||
}); | ||
The classes | ||
----------- | ||
describe("when testing a scenario", () => { | ||
const { getByText } = component | ||
.withProps({ | ||
prop1: "Scenario value 1" | ||
}) | ||
.mount(); | ||
it("uses the scenario-specific value for prop1", () => { | ||
expect(getByText("Scenario value 1")).toBeDefined(); | ||
}); | ||
it("uses the default value for prop2", () => { | ||
expect(getByText("Default value 2")).toBeDefined(); | ||
}); | ||
}); | ||
``` | ||
Package contents | ||
---------------- | ||
- [`Wrapper`](./docs/Wrapper.md) | ||
- [`WrapperWithIntl`](./docs/WrapperWithIntl.md) | ||
- [`WrapperWithRedux`](./docs/WrapperWithRedux.md) | ||
- [Custom `react-testing-library` queries](./docs/react-testing-library/queries.md) |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
99767
32
1839
82
7
31
1