@wordpress/jest-preset-default 9.1.0 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -0
- package/jest-preset.js +0 -1
- package/package.json +5 -9
- package/scripts/setup-test-framework.js +0 -20
- package/CHANGELOG.md +0 -152
package/README.md
CHANGED
|
@@ -36,6 +36,64 @@ npm install @wordpress/jest-preset-default --save-dev
|
|
|
36
36
|
- `transform` - keeps the default [babel-jest](https://github.com/facebook/jest/tree/HEAD/packages/babel-jest) transformer.
|
|
37
37
|
- `verbose` - each individual test won't be reported during the run.
|
|
38
38
|
|
|
39
|
+
#### Using enzyme
|
|
40
|
+
|
|
41
|
+
Historically, this package used to use `enzyme`, but support was dropped in favor of `@testing-library/react`, primary reason being unblocking the upgrade to React 18.
|
|
42
|
+
|
|
43
|
+
If you wish to use `enzyme`, you can still use it by manually providing the React 17 adapter, by following the steps below.
|
|
44
|
+
|
|
45
|
+
To install the enzyme dependency, run:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm install --save enzyme
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
To install the React 17 adapter dependency, run:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npm install --save @wojtekmaj/enzyme-adapter-react-17
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
To use the React 17 adapter, use this in your [`setupFilesAfterEnv`](https://jestjs.io/docs/configuration#setupfilesafterenv-array) configuration:
|
|
58
|
+
|
|
59
|
+
```javascript
|
|
60
|
+
// It "mocks" enzyme, so that we can delay loading of
|
|
61
|
+
// the utility functions until enzyme is imported in tests.
|
|
62
|
+
// Props to @gdborton for sharing this technique in his article:
|
|
63
|
+
// https://medium.com/airbnb-engineering/unlocking-test-performance-migrating-from-mocha-to-jest-2796c508ec50.
|
|
64
|
+
let mockEnzymeSetup = false;
|
|
65
|
+
|
|
66
|
+
jest.mock( 'enzyme', () => {
|
|
67
|
+
const actualEnzyme = jest.requireActual( 'enzyme' );
|
|
68
|
+
if ( ! mockEnzymeSetup ) {
|
|
69
|
+
mockEnzymeSetup = true;
|
|
70
|
+
|
|
71
|
+
// Configure enzyme 3 for React, from docs: http://airbnb.io/enzyme/docs/installation/index.html
|
|
72
|
+
const Adapter = jest.requireActual(
|
|
73
|
+
'@wojtekmaj/enzyme-adapter-react-17'
|
|
74
|
+
);
|
|
75
|
+
actualEnzyme.configure( { adapter: new Adapter() } );
|
|
76
|
+
}
|
|
77
|
+
return actualEnzyme;
|
|
78
|
+
} );
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
If you also use snapshot tests with `enzyme`, you might want to add support for serializing them, through the `enzyme-to-json` package.
|
|
82
|
+
|
|
83
|
+
To install the dependency, run:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
npm install --save enzyme-to-json
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Finally, you should add `enzyme-to-json/serializer` to the array of [`snapshotSerializers`](https://jestjs.io/docs/configuration#snapshotserializers-arraystring):
|
|
90
|
+
|
|
91
|
+
```javascript
|
|
92
|
+
{
|
|
93
|
+
snapshotSerializers: [ 'enzyme-to-json/serializer' ]
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
39
97
|
## Contributing to this package
|
|
40
98
|
|
|
41
99
|
This is an individual package that's part of the Gutenberg project. The project is organized as a monorepo. It's made up of multiple self-contained software packages, each with a specific purpose. The packages in this monorepo are published to [npm](https://www.npmjs.com/) and used by [WordPress](https://make.wordpress.org/core/) as well as other software projects.
|
package/jest-preset.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/jest-preset-default",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"description": "Default Jest preset for WordPress development.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
"gutenberg",
|
|
10
10
|
"jest",
|
|
11
11
|
"preset",
|
|
12
|
-
"react"
|
|
13
|
-
"enzyme"
|
|
12
|
+
"react"
|
|
14
13
|
],
|
|
15
14
|
"homepage": "https://github.com/WordPress/gutenberg/tree/HEAD/packages/jest-preset-default/README.md",
|
|
16
15
|
"repository": {
|
|
@@ -31,11 +30,8 @@
|
|
|
31
30
|
],
|
|
32
31
|
"main": "index.js",
|
|
33
32
|
"dependencies": {
|
|
34
|
-
"@
|
|
35
|
-
"
|
|
36
|
-
"babel-jest": "^27.4.5",
|
|
37
|
-
"enzyme": "^3.11.0",
|
|
38
|
-
"enzyme-to-json": "^3.4.4"
|
|
33
|
+
"@wordpress/jest-console": "^6.2.0",
|
|
34
|
+
"babel-jest": "^27.4.5"
|
|
39
35
|
},
|
|
40
36
|
"peerDependencies": {
|
|
41
37
|
"@babel/core": ">=7",
|
|
@@ -46,5 +42,5 @@
|
|
|
46
42
|
"publishConfig": {
|
|
47
43
|
"access": "public"
|
|
48
44
|
},
|
|
49
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "8d42d2febb7d0ba8372a33e560a62f5a5f6a9112"
|
|
50
46
|
}
|
|
@@ -1,21 +1 @@
|
|
|
1
1
|
require( '@wordpress/jest-console' );
|
|
2
|
-
|
|
3
|
-
// It "mocks" enzyme, so that we can delay loading of
|
|
4
|
-
// the utility functions until enzyme is imported in tests.
|
|
5
|
-
// Props to @gdborton for sharing this technique in his article:
|
|
6
|
-
// https://medium.com/airbnb-engineering/unlocking-test-performance-migrating-from-mocha-to-jest-2796c508ec50.
|
|
7
|
-
let mockEnzymeSetup = false;
|
|
8
|
-
|
|
9
|
-
jest.mock( 'enzyme', () => {
|
|
10
|
-
const actualEnzyme = jest.requireActual( 'enzyme' );
|
|
11
|
-
if ( ! mockEnzymeSetup ) {
|
|
12
|
-
mockEnzymeSetup = true;
|
|
13
|
-
|
|
14
|
-
// Configure enzyme 3 for React, from docs: http://airbnb.io/enzyme/docs/installation/index.html
|
|
15
|
-
const Adapter = jest.requireActual(
|
|
16
|
-
'@wojtekmaj/enzyme-adapter-react-17'
|
|
17
|
-
);
|
|
18
|
-
actualEnzyme.configure( { adapter: new Adapter() } );
|
|
19
|
-
}
|
|
20
|
-
return actualEnzyme;
|
|
21
|
-
} );
|
package/CHANGELOG.md
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
<!-- Learn how to maintain this file at https://github.com/WordPress/gutenberg/tree/HEAD/packages#maintaining-changelogs. -->
|
|
2
|
-
|
|
3
|
-
## Unreleased
|
|
4
|
-
|
|
5
|
-
## 9.1.0 (2022-09-21)
|
|
6
|
-
|
|
7
|
-
## 9.0.0 (2022-08-24)
|
|
8
|
-
|
|
9
|
-
### Breaking Change
|
|
10
|
-
|
|
11
|
-
- Increase the minimum Node.js version to 14 ([#43141](https://github.com/WordPress/gutenberg/pull/43141)).
|
|
12
|
-
|
|
13
|
-
### Bug Fix
|
|
14
|
-
|
|
15
|
-
- Packages: Replace `is-plain-obj` with `is-plain-object` ([#43511](https://github.com/WordPress/gutenberg/pull/43511)).
|
|
16
|
-
|
|
17
|
-
## 8.5.2 (2022-08-17)
|
|
18
|
-
|
|
19
|
-
### Bug Fix
|
|
20
|
-
|
|
21
|
-
- Jest Preset: Improve `is-plain-obj` transformation ignore ([#43271](https://github.com/WordPress/gutenberg/pull/43271)).
|
|
22
|
-
|
|
23
|
-
## 8.5.1 (2022-08-12)
|
|
24
|
-
|
|
25
|
-
### Bug Fix
|
|
26
|
-
|
|
27
|
-
- Jest Preset: Ignore `is-plain-obj` transformation ([#43179](https://github.com/WordPress/gutenberg/pull/43179)).
|
|
28
|
-
|
|
29
|
-
## 8.0.0 (2022-01-27)
|
|
30
|
-
|
|
31
|
-
### Breaking Changes
|
|
32
|
-
|
|
33
|
-
- The peer `jest` dependency has been updated from requiring `>=26` to requiring `>=27` (see [Breaking Changes](https://jestjs.io/blog/2021/05/25/jest-27), [#33287](https://github.com/WordPress/gutenberg/pull/33287)).
|
|
34
|
-
|
|
35
|
-
### Bug Fixes
|
|
36
|
-
|
|
37
|
-
- Allow ESLint to be imported from within Jest (e.g. when using `ruleTester`) ([#36283](https://github.com/WordPress/gutenberg/pull/36283)).
|
|
38
|
-
- Improve support for test files with `.jsx` and `.tsx` extensions ([#36260](https://github.com/WordPress/gutenberg/pull/36260)).
|
|
39
|
-
|
|
40
|
-
## 7.1.2 (2021-10-22)
|
|
41
|
-
|
|
42
|
-
### Bug Fix
|
|
43
|
-
|
|
44
|
-
- Provide more complete mocks of browser timing functions. ([#35368](https://github.com/WordPress/gutenberg/pull/35368))
|
|
45
|
-
|
|
46
|
-
## 7.1.1 (2021-09-09)
|
|
47
|
-
|
|
48
|
-
### Bug Fix
|
|
49
|
-
|
|
50
|
-
- Restore the default setting for the `verbose` option. In effect, each test won't get reported during the run ([#34327](https://github.com/WordPress/gutenberg/pull/34327)).
|
|
51
|
-
|
|
52
|
-
## 7.0.0 (2021-01-21)
|
|
53
|
-
|
|
54
|
-
### Breaking Changes
|
|
55
|
-
|
|
56
|
-
- The peer `jest` dependency has been updated from requiring `>=25` to requiring `>=26` (see [Breaking Changes](https://jestjs.io/blog/2020/05/05/jest-26), [#27956](https://github.com/WordPress/gutenberg/pull/27956)).
|
|
57
|
-
|
|
58
|
-
## 6.5.0 (2020-10-30)
|
|
59
|
-
|
|
60
|
-
### Enhancements
|
|
61
|
-
|
|
62
|
-
- Ignore `/vendor` folder when searching for tests.
|
|
63
|
-
|
|
64
|
-
## 6.0.0 (2020-04-15)
|
|
65
|
-
|
|
66
|
-
### Breaking Changes
|
|
67
|
-
|
|
68
|
-
- The peer `jest` dependency has been updated from requiring `>=24` to requiring `>=25` (see [Breaking Changes](https://jestjs.io/blog/2020/01/21/jest-25), [#20766](https://github.com/WordPress/gutenberg/pull/20766)).
|
|
69
|
-
- This package requires now `node` v10.0.0 or later ([#20766](https://github.com/WordPress/gutenberg/pull/20766)).
|
|
70
|
-
|
|
71
|
-
## 5.4.0 (2020-02-04)
|
|
72
|
-
|
|
73
|
-
### Bug Fixes
|
|
74
|
-
|
|
75
|
-
- Use `require.resolve()` instead of `<rootDir>` to resolve `jest` config files according to the NodeJS lookup algorithm. ([#19957](https://github.com/WordPress/gutenberg/pull/19957))
|
|
76
|
-
|
|
77
|
-
## 5.3.1 (2020-01-01)
|
|
78
|
-
|
|
79
|
-
### Bug Fixes
|
|
80
|
-
|
|
81
|
-
- Fix preset file extension for inclusion in NPM deployments. ([#19306](https://github.com/WordPress/gutenberg/pull/19306)).
|
|
82
|
-
|
|
83
|
-
## 5.3.0 (2019-12-20)
|
|
84
|
-
|
|
85
|
-
### New Features
|
|
86
|
-
|
|
87
|
-
- Added support to collapse or omit successful test results from Travis CI builds ([#16744](https://github.com/WordPress/gutenberg/issues/16744))
|
|
88
|
-
|
|
89
|
-
## 5.2.0 (2019-11-15)
|
|
90
|
-
|
|
91
|
-
## 5.1.0 (2019-09-03)
|
|
92
|
-
|
|
93
|
-
### Bug Fixes
|
|
94
|
-
|
|
95
|
-
- Add `wordpress` folder to the list of ignored paths ([#17296](https://github.com/WordPress/gutenberg/pull/17296)).
|
|
96
|
-
|
|
97
|
-
## 5.0.0 (2019-08-29)
|
|
98
|
-
|
|
99
|
-
### Breaking Changes
|
|
100
|
-
|
|
101
|
-
- Files with `.spec.js` suffix are no longer matched as test files by default.
|
|
102
|
-
|
|
103
|
-
### New Features
|
|
104
|
-
|
|
105
|
-
- Align `testMatch` config option with Jest and allow test files with `.ts` suffix.
|
|
106
|
-
|
|
107
|
-
## 4.0.0 (2019-03-06)
|
|
108
|
-
|
|
109
|
-
### Breaking Changes
|
|
110
|
-
|
|
111
|
-
- The bundled `jest` dependency has been updated from requiring `^23.6.0` to requiring `^24.1.0` (see [Breaking Changes](https://jestjs.io/blog/2019/01/25/jest-24-refreshing-polished-typescript-friendly#breaking-changes), [#13922](https://github.com/WordPress/gutenberg/pull/13922)).
|
|
112
|
-
- The bundled `jest-enzyme` dependency has been removed completely ([#13922](https://github.com/WordPress/gutenberg/pull/13922)).
|
|
113
|
-
|
|
114
|
-
### Internal
|
|
115
|
-
|
|
116
|
-
- The bundled `enzyme` dependency has been updated from requiring `^3.7.0` to requiring `^3.9.0` ([#13922](https://github.com/WordPress/gutenberg/pull/13922)).
|
|
117
|
-
- The bundled `enzyme-adapter-react-16` dependency has been updated from requiring `^1.6.0` to requiring `^1.10.0` ([#13922](https://github.com/WordPress/gutenberg/pull/13922)).
|
|
118
|
-
|
|
119
|
-
## 3.0.3 (2018-11-20)
|
|
120
|
-
|
|
121
|
-
## 3.0.2 (2018-11-09)
|
|
122
|
-
|
|
123
|
-
## 3.0.1 (2018-11-09)
|
|
124
|
-
|
|
125
|
-
## 3.0.0 (2018-11-03)
|
|
126
|
-
|
|
127
|
-
### Breaking Change
|
|
128
|
-
|
|
129
|
-
- Remove coverage support.
|
|
130
|
-
|
|
131
|
-
## 2.0.0 (2018-07-12)
|
|
132
|
-
|
|
133
|
-
### Breaking Change
|
|
134
|
-
|
|
135
|
-
- Updated code to work with Babel 7 ([#7832](https://github.com/WordPress/gutenberg/pull/7832))
|
|
136
|
-
|
|
137
|
-
### Internal
|
|
138
|
-
|
|
139
|
-
- Moved `@WordPress/packages` repository to `@WordPress/gutenberg` ([#7805](https://github.com/WordPress/gutenberg/pull/7805))
|
|
140
|
-
|
|
141
|
-
## 1.0.6 (2018-05-18)
|
|
142
|
-
|
|
143
|
-
### Polish
|
|
144
|
-
|
|
145
|
-
- Fix: Standardized `package.json` format ([#119](https://github.com/WordPress/packages/pull/119))
|
|
146
|
-
|
|
147
|
-
## 1.0.5 (2018-03-22)
|
|
148
|
-
|
|
149
|
-
### Polish
|
|
150
|
-
|
|
151
|
-
- Docs: Wrap filename in backticks ([#89](https://github.com/WordPress/packages/pull/89))
|
|
152
|
-
- Add `jest-preset` keyword to `jest-preset-default` package ([#92](https://github.com/WordPress/packages/pull/92))
|