Skip to content

Commit 76b747c

Browse files
author
Raice Hannay
committed
upgrade react + remove enyzme support
1 parent 4ffb9ed commit 76b747c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2751
-3709
lines changed

Diff for: .gitignore

+8-11
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1-
# Logs
1+
#Logs
22
logs
33
*.log
44

55
#project
66
coverage
77
dist
8-
lib
9-
/enzyme/
10-
/react-testing-library/
8+
./cjs
9+
./esm
10+
*.js
11+
*.d.ts
12+
*.tgz
13+
*.map
1114

1215
#node
1316
node_modules
1417
npm-debug.log
1518
yarn.error.l
16-
*.tgz
19+
package-lock.json
1720

1821
#IDEs
1922
.idea
@@ -29,9 +32,3 @@ yarn.error.l
2932

3033
#git hooks
3134
pre-commit.sh
32-
33-
#.teamcity
34-
.teamcity/target/
35-
.teamcity/.classpath
36-
.teamcity/.settings/
37-
.teamcity/.project

Diff for: README.md

+4-37
Original file line numberDiff line numberDiff line change
@@ -12,42 +12,16 @@ project requires additional functionality as part of your component test setup.
1212
The concept behind it is that you can create a single instance of the wrapper class at the top of
1313
your test file and define the defaults to use there, then in each test scenario you can reference
1414
the single instance and define the scenario-specific props/children etc. chaining the public methods,
15-
then finally calling the `mount`, `shallow` or `render` method (only `render` is available in the
16-
`react-testing-library` variants) to return the rendering result.
15+
then finally calling the `render` method to return the rendering result.
1716

18-
The scenario-specific definitions are reset each time you call `mount`, `render` or `shallow`, which
17+
The scenario-specific definitions are reset each time you call `render`, which
1918
will ensure it reverts back to only the defaults set at the top and prevents scenario data from leaking
2019
between tests.
2120

2221
## Example
23-
### With `enzyme`
2422
```typescript jsx
25-
const component = new Wrapper(SomeComponent)
26-
.withDefaultChildren(<div className="Child" />)
27-
.withDefaultProps({
28-
prop1: "Default value 1",
29-
prop2: "Default value 2"
30-
});
31-
32-
describe("when testing a scenario", () => {
33-
const wrapper = component
34-
.withProps({
35-
prop1: "Scenario value 1"
36-
})
37-
.mount();
23+
import { Wrapper } from "react-test-wrapper";
3824

39-
it("uses the scenario-specific value for prop1", () => {
40-
expect(wrapper.find(".SomeComponent--prop1").text()).toBe("Scenario value 1");
41-
});
42-
43-
it("uses the default value for prop2", () => {
44-
expect(wrapper.find(".SomeComponent--prop2").text()).toBe("Default value 1");
45-
});
46-
});
47-
```
48-
49-
### With `react-testing-library`
50-
```typescript jsx
5125
const component = new Wrapper(SomeComponent)
5226
.withDefaultChildren(<div className="Child" />)
5327
.withDefaultProps({
@@ -60,7 +34,7 @@ describe("when testing a scenario", () => {
6034
.withProps({
6135
prop1: "Scenario value 1"
6236
})
63-
.mount();
37+
.render();
6438

6539
it("uses the scenario-specific value for prop1", () => {
6640
expect(getByText("Scenario value 1")).toBeDefined();
@@ -74,13 +48,6 @@ describe("when testing a scenario", () => {
7448

7549
Package contents
7650
----------------
77-
78-
## For `enzyme`
79-
- [`Wrapper`](/docs/enzyme/Wrapper.md)
80-
- [`WrapperWithIntl`](/docs/enzyme/WrapperWithIntl.md)
81-
- [`WrapperWithRedux`](/docs/enzyme/WrapperWithRedux.md)
82-
83-
## For `react-testing-library`
8451
- [`Wrapper`](/docs/react-testing-library/Wrapper.md)
8552
- [`WrapperWithIntl`](/docs/react-testing-library/WrapperWithIntl.md)
8653
- [`WrapperWithRedux`](/docs/react-testing-library/WrapperWithRedux.md)

Diff for: cjs/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "commonjs"
3+
}

Diff for: docs/enzyme/Wrapper.md

-81
This file was deleted.

Diff for: docs/enzyme/WrapperWithIntl.md

-34
This file was deleted.

Diff for: docs/enzyme/WrapperWithRedux.md

-104
This file was deleted.

Diff for: docs/react-testing-library/Wrapper.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ exist in the React tree.
5757

5858
```typescript jsx
5959
import * as React from "react";
60-
import { Wrapper as BaseWrapper } from "react-test-wrapper/react-testing-library";
60+
import { Wrapper as BaseWrapper } from "react-test-wrapper";
6161

6262
export class WrapperWithCustomStuff<
6363
C extends React.ComponentType<any>,

Diff for: docs/react-testing-library/WrapperWithIntl.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ How to extend for use in your project
1919
```typescript jsx
2020
import * as React from "react";
2121
import { IntlConfig } from "react-intl";
22-
import { WrapperWithIntl as BaseWrapper } from "react-test-wrapper/react-testing-library";
22+
import { WrapperWithIntl as BaseWrapper } from "react-test-wrapper";
2323

2424
import messages from "./locales/en-NZ";
2525

Diff for: docs/react-testing-library/WrapperWithRedux.md

+3-10
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@ define your own `createStore` method to return an instance of your Redux store,
99
`initialState` and `middlewares` that this class provides - it is important to ensure that your
1010
store uses these, because if it disregards them, none of the methods this class provides will function.
1111

12-
Extensions to the returned `ReduxWrapper`
13-
-----------------------------------------
14-
15-
The return type of the `mount` method extends Enzyme's `ReactWrapper` by adding a store property to
16-
it, so you can access the store instance that the component was mounted with. This is useful for
17-
some edge cases where you may want to test how your component reacts to actions being dispatched
18-
outside of the component's scope.
1912

2013
For example:
2114
```typescript jsx
@@ -28,7 +21,7 @@ describe("when testing a scenario", () => {
2821
value: "Scenario value 1"
2922
}
3023
})
31-
.mount();
24+
.render();
3225

3326
it("renders the initial value", () => {
3427
expect(wrapper.find(".SomeComponent--value").text()).toBe("Initial value");
@@ -69,7 +62,7 @@ Sets the scenario-specific Redux store state to be used - cleared after `render`
6962
Toggles whether arrays get merged or not in Redux state.
7063

7164
### `render`
72-
Mounts the component with the `react-testing-library` `render` function, using the currently-set data.
65+
Mounts the component with the React Testing Library `render` function, using the currently-set data.
7366
Returns a `RenderResult` instance, which also includes a `store` property.
7467

7568

@@ -78,7 +71,7 @@ How to extend for use in your project
7871

7972
```typescript jsx
8073
import * as React from "react";
81-
import { WrapperWithRedux as BaseWrapper } from "react-test-wrapper/react-testing-library";
74+
import { WrapperWithRedux as BaseWrapper } from "react-test-wrapper";
8275

8376
import { createStore, TStoreState } from "../store";
8477

0 commit comments

Comments
 (0)