Skip to content

Commit 341f941

Browse files
committed
chore: migrate pretty-format to ESM
1 parent 30b6cee commit 341f941

41 files changed

Lines changed: 191 additions & 121 deletions

Some content is hidden

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

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
### Fixes
88

99
- `[jest-transform]` Show enhanced `SyntaxError` message for all `SyntaxError`s ([#10749](https://github.com/facebook/jest/pull/10749))
10+
- `[pretty-format]` [**BREAKING**] Convert to ES Modules ([#10515](https://github.com/facebook/jest/pull/10515))
1011

1112
### Chore & Maintenance
1213

docs/JestPlatform.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ Exports a function that converts any JavaScript value into a human-readable stri
160160
### Example
161161

162162
```javascript
163-
const prettyFormat = require('pretty-format');
163+
const {format: prettyFormat} = require('pretty-format');
164164

165165
const val = {object: {}};
166166
val.circularReference = val;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@
141141
"node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0"
142142
},
143143
"resolutions": {
144+
"@testing-library/dom": "patch:@testing-library/dom@*#./patches/dom-testing.diff",
144145
"@types/jest/jest-diff": "^25.1.0",
145146
"@types/jest/pretty-format": "^25.1.0"
146147
}

packages/jest-circus/src/formatNodeAssertErrors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
printExpected,
1515
printReceived,
1616
} from 'jest-matcher-utils';
17-
import prettyFormat = require('pretty-format');
17+
import prettyFormat from 'pretty-format';
1818

1919
interface AssertionErrorWithStack extends AssertionError {
2020
stack: string;

packages/jest-circus/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import StackUtils = require('stack-utils');
1313
import type {AssertionResult, Status} from '@jest/test-result';
1414
import type {Circus} from '@jest/types';
1515
import {ErrorWithStack, convertDescriptorToString, formatTime} from 'jest-util';
16-
import prettyFormat = require('pretty-format');
16+
import prettyFormat from 'pretty-format';
1717
import {ROOT_DESCRIBE_BLOCK_NAME, getState} from './state';
1818

1919
const stackUtils = new StackUtils({cwd: 'A path that does not exist'});

packages/jest-config/src/Deprecated.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import chalk = require('chalk');
99
import type {DeprecatedOptions} from 'jest-validate';
10-
import prettyFormat = require('pretty-format');
10+
import prettyFormat from 'pretty-format';
1111

1212
const format = (value: unknown) => prettyFormat(value, {min: true});
1313

packages/jest-diff/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ You might call this function for case insensitive or Unicode equivalence compari
165165
### Example of diffLinesUnified2
166166

167167
```js
168-
import format from 'pretty-format';
168+
import {format} from 'pretty-format';
169169

170170
const a = {
171171
text: 'Ignore indentation in serialized object',

packages/jest-diff/src/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77

88
import chalk = require('chalk');
99
import getType = require('jest-get-type');
10-
import prettyFormat = require('pretty-format');
10+
import {
11+
format as prettyFormat,
12+
plugins as prettyFormatPlugins,
13+
} from 'pretty-format';
1114
import {DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff} from './cleanupSemantic';
1215
import {NO_DIFF_MESSAGE, SIMILAR_MESSAGE} from './constants';
1316
import {diffLinesRaw, diffLinesUnified, diffLinesUnified2} from './diffLines';
@@ -33,7 +36,7 @@ const {
3336
Immutable,
3437
ReactElement,
3538
ReactTestComponent,
36-
} = prettyFormat.plugins;
39+
} = prettyFormatPlugins;
3740

3841
const PLUGINS = [
3942
ReactTestComponent,

packages/jest-each/src/__tests__/array.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
*/
88

9-
import pretty = require('pretty-format');
9+
import {format as pretty} from 'pretty-format';
1010
import each from '../';
1111

1212
const noop = () => {};

packages/jest-each/src/table/array.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import * as util from 'util';
1010
import type {Global} from '@jest/types';
11-
import pretty = require('pretty-format');
11+
import {format as pretty} from 'pretty-format';
1212
import type {EachTests} from '../bind';
1313

1414
const SUPPORTED_PLACEHOLDERS = /%[sdifjoOp%]/g;

0 commit comments

Comments
 (0)