Skip to content

Commit

Permalink
Get green
Browse files Browse the repository at this point in the history
  • Loading branch information
orta committed Jul 12, 2021
1 parent 8395cdf commit 8d5ea2e
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 11 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.md
Expand Up @@ -2,8 +2,7 @@

### Features

- `[jest-cli]` Adds an option (`inlineSnapshotFormatter` with `simple`) for having inline snapshot serializers use the printBasicPrototype option to show literals as literals. ([#11654](https://github.com/facebook/jest/pull/11654))

- `[jest-cli]` Adds 2 config ptions (`inlineSnapshotFormatter` and `snapshotFormat`) which offers a way to override any of the formatting settings which come with [pretty-format](https://www.npmjs.com/package/pretty-format#usage-with-options). ([#11654](https://github.com/facebook/jest/pull/11654))

### Fixes

Expand Down
58 changes: 58 additions & 0 deletions docs/Configuration.md
Expand Up @@ -537,6 +537,45 @@ test('some test', () => {

_Note: This option is only supported using the default `jest-circus`. test runner_


### `inlineSnapshotFormat` \[object]

Default: `undefined`

Allows to overriding specific snapshot formatting options documented in the [pretty-format readme](https://www.npmjs.com/package/pretty-format#usage-with-options). For example, this config would have the inline snapshot formatter not print a prefix for "Object" and "Array":

```json
{
"jest": {
"inlineSnapshotFormat": {
"printBasicPrototype": false
},
}
}
```

```ts
import {expect, test} from '@jest/globals';

test('does not show prototypes for object and array inline', () => {
const object = {
array: [{hello: 'Danger'}],
};
expect(object).toMatchInlineSnapshot(`
{
"array": [
{
"hello": "Danger",
},
],
}
`);
});
```

There is a corresponding [`snapshotFormat`](#snapshotformat-object) option for separate file snapshots.


### `maxConcurrency` \[number]

Default: `5`
Expand Down Expand Up @@ -945,6 +984,25 @@ Default: `5`

The number of seconds after which a test is considered as slow and reported as such in the results.


### `snapshotFormat` \[object]

Default: `undefined`

Allows to overriding specific snapshot formatting options documented in the [pretty-format readme](https://www.npmjs.com/package/pretty-format#usage-with-options). For example, this config would have the snapshot formatter which prints with 4 spaces instead of 2:

```json
{
"jest": {
"snapshotFormat": {
"indent": 4
},
}
}
```

There is a corresponding [`inlineSnapshotFormat`](#inlinesnapshotformat-object) option for inline snapshots.

### `snapshotResolver` \[string]

Default: `undefined`
Expand Down
Expand Up @@ -18,6 +18,7 @@ exports[`prints the config object 1`] = `
"globals": {},
"haste": {},
"injectGlobals": true,
"inlineSnapshotFormat": {},
"moduleDirectories": [],
"moduleFileExtensions": [
"js"
Expand All @@ -41,6 +42,7 @@ exports[`prints the config object 1`] = `
"skipFilter": false,
"skipNodeResolution": false,
"slowTestThreshold": 5,
"snapshotFormat": {},
"snapshotSerializers": [],
"testEnvironment": "node",
"testEnvironmentOptions": {},
Expand Down Expand Up @@ -75,6 +77,7 @@ exports[`prints the config object 1`] = `
"expand": false,
"findRelatedTests": false,
"forceExit": false,
"inlineSnapshotFormat": {},
"json": false,
"lastCommit": false,
"listTests": false,
Expand All @@ -94,6 +97,7 @@ exports[`prints the config object 1`] = `
"runTestsByPath": false,
"silent": false,
"skipFilter": false,
"snapshotFormat": {},
"testFailureExitCode": 1,
"testNamePattern": "",
"testPathPattern": "",
Expand Down
1 change: 0 additions & 1 deletion packages/jest-snapshot/src/State.ts
Expand Up @@ -26,7 +26,6 @@ export type SnapshotStateOptions = {
updateSnapshot: Config.SnapshotUpdateState;
prettierPath: Config.Path;
expand?: boolean;
preferSimpleForInline?: boolean;
snapshotFormat: PrettyFormatOptions;
inlineSnapshotFormat: PrettyFormatOptions;
};
Expand Down

0 comments on commit 8d5ea2e

Please sign in to comment.