Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the new serializer plugin API in example #9847

Merged
merged 1 commit into from
Apr 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -830,8 +830,8 @@ Example serializer module:
```js
// my-serializer-module
module.exports = {
print(val, serialize, indent) {
return 'Pretty foo: ' + serialize(val.foo);
serialize(val, config, indentation, depth, refs, printer) {
return 'Pretty foo: ' + printer(val.foo);
},

test(val) {
Expand All @@ -840,7 +840,7 @@ module.exports = {
};
```

`serialize` is a function that serializes a value using existing plugins.
`printer` is a function that serializes a value using existing plugins.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where does this printer name come from?

Copy link
Contributor Author

@Andarist Andarist Apr 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


To use `my-serializer-module` as a serializer, configuration would be as follows:

Expand Down Expand Up @@ -879,6 +879,8 @@ Pretty foo: Object {

To make a dependency explicit instead of implicit, you can call [`expect.addSnapshotSerializer`](ExpectAPI.md#expectaddsnapshotserializerserializer) to add a module for an individual test file instead of adding its path to `snapshotSerializers` in Jest configuration.

More about serializers API can be found [here](https://github.com/facebook/jest/tree/master/packages/pretty-format/README.md#serialize).

### `testEnvironment` [string]

Default: `"jsdom"`
Expand Down
8 changes: 5 additions & 3 deletions website/versioned_docs/version-22.x/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,8 @@ Example serializer module:
```js
// my-serializer-module
module.exports = {
print(val, serialize, indent) {
return 'Pretty foo: ' + serialize(val.foo);
serialize(val, config, indentation, depth, refs, printer) {
return 'Pretty foo: ' + printer(val.foo);
},

test(val) {
Expand All @@ -608,7 +608,7 @@ module.exports = {
};
```

`serialize` is a function that serializes a value using existing plugins.
`printer` is a function that serializes a value using existing plugins.

To use `my-serializer-module` as a serializer, configuration would be as follows:

Expand Down Expand Up @@ -647,6 +647,8 @@ Pretty foo: Object {

To make a dependency explicit instead of implicit, you can call [`expect.addSnapshotSerializer`](ExpectAPI.md#expectaddsnapshotserializerserializer) to add a module for an individual test file instead of adding its path to `snapshotSerializers` in Jest configuration.

More about serializers API can be found [here](https://github.com/facebook/jest/tree/master/packages/pretty-format#serialize).

### `testEnvironment` [string]

Default: `"jsdom"`
Expand Down
8 changes: 5 additions & 3 deletions website/versioned_docs/version-23.x/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,8 @@ Example serializer module:
```js
// my-serializer-module
module.exports = {
print(val, serialize, indent) {
return 'Pretty foo: ' + serialize(val.foo);
serialize(val, config, indentation, depth, refs, printer) {
return 'Pretty foo: ' + printer(val.foo);
},

test(val) {
Expand All @@ -672,7 +672,7 @@ module.exports = {
};
```

`serialize` is a function that serializes a value using existing plugins.
`printer` is a function that serializes a value using existing plugins.

To use `my-serializer-module` as a serializer, configuration would be as follows:

Expand Down Expand Up @@ -711,6 +711,8 @@ Pretty foo: Object {

To make a dependency explicit instead of implicit, you can call [`expect.addSnapshotSerializer`](ExpectAPI.md#expectaddsnapshotserializerserializer) to add a module for an individual test file instead of adding its path to `snapshotSerializers` in Jest configuration.

More about serializers API can be found [here](https://github.com/facebook/jest/tree/master/packages/pretty-format#serialize).

### `testEnvironment` [string]

Default: `"jsdom"`
Expand Down
8 changes: 5 additions & 3 deletions website/versioned_docs/version-24.x/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -807,8 +807,8 @@ Example serializer module:
```js
// my-serializer-module
module.exports = {
print(val, serialize, indent) {
return 'Pretty foo: ' + serialize(val.foo);
serialize(val, config, indentation, depth, refs, printer) {
return 'Pretty foo: ' + printer(val.foo);
},

test(val) {
Expand All @@ -817,7 +817,7 @@ module.exports = {
};
```

`serialize` is a function that serializes a value using existing plugins.
`printer` is a function that serializes a value using existing plugins.

To use `my-serializer-module` as a serializer, configuration would be as follows:

Expand Down Expand Up @@ -856,6 +856,8 @@ Pretty foo: Object {

To make a dependency explicit instead of implicit, you can call [`expect.addSnapshotSerializer`](ExpectAPI.md#expectaddsnapshotserializerserializer) to add a module for an individual test file instead of adding its path to `snapshotSerializers` in Jest configuration.

More about serializers API can be found [here](https://github.com/facebook/jest/tree/master/packages/pretty-format#serialize).

### `testEnvironment` [string]

Default: `"jsdom"`
Expand Down
8 changes: 5 additions & 3 deletions website/versioned_docs/version-25.1/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -818,8 +818,8 @@ Example serializer module:
```js
// my-serializer-module
module.exports = {
print(val, serialize, indent) {
return 'Pretty foo: ' + serialize(val.foo);
serialize(val, config, indentation, depth, refs, printer) {
return 'Pretty foo: ' + printer(val.foo);
},

test(val) {
Expand All @@ -828,7 +828,7 @@ module.exports = {
};
```

`serialize` is a function that serializes a value using existing plugins.
`printer` is a function that serializes a value using existing plugins.

To use `my-serializer-module` as a serializer, configuration would be as follows:

Expand Down Expand Up @@ -867,6 +867,8 @@ Pretty foo: Object {

To make a dependency explicit instead of implicit, you can call [`expect.addSnapshotSerializer`](ExpectAPI.md#expectaddsnapshotserializerserializer) to add a module for an individual test file instead of adding its path to `snapshotSerializers` in Jest configuration.

More about serializers API can be found [here](https://github.com/facebook/jest/tree/master/packages/pretty-format#serialize).

### `testEnvironment` [string]

Default: `"jsdom"`
Expand Down
8 changes: 5 additions & 3 deletions website/versioned_docs/version-25.3/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -831,8 +831,8 @@ Example serializer module:
```js
// my-serializer-module
module.exports = {
print(val, serialize, indent) {
return 'Pretty foo: ' + serialize(val.foo);
serialize(val, config, indentation, depth, refs, printer) {
return 'Pretty foo: ' + printer(val.foo);
},

test(val) {
Expand All @@ -841,7 +841,7 @@ module.exports = {
};
```

`serialize` is a function that serializes a value using existing plugins.
`printer` is a function that serializes a value using existing plugins.

To use `my-serializer-module` as a serializer, configuration would be as follows:

Expand Down Expand Up @@ -880,6 +880,8 @@ Pretty foo: Object {

To make a dependency explicit instead of implicit, you can call [`expect.addSnapshotSerializer`](ExpectAPI.md#expectaddsnapshotserializerserializer) to add a module for an individual test file instead of adding its path to `snapshotSerializers` in Jest configuration.

More about serializers API can be found [here](https://github.com/facebook/jest/tree/master/packages/pretty-format#serialize).

### `testEnvironment` [string]

Default: `"jsdom"`
Expand Down