Skip to content

Commit

Permalink
Use the new serializer plugin API in example (#9847)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Apr 26, 2020
1 parent 673eb49 commit 4a142ec
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 18 deletions.
8 changes: 5 additions & 3 deletions docs/Configuration.md
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.

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
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
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
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
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
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

0 comments on commit 4a142ec

Please sign in to comment.