Skip to content

Commit

Permalink
E2E wpDataSelect: Explain why undefined is returned sometimes (#31227)
Browse files Browse the repository at this point in the history
  • Loading branch information
david-szabo97 authored May 3, 2021
1 parent cfad7f3 commit ab2a61a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/e2e-test-utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,19 @@ _Parameters_

Queries the WordPress data module.

`page.evaluate` - used in the function - returns `undefined`
when it encounters a non-serializable value.
Since we store many different values in the data module,
you can end up with an `undefined` result. Before using
this function, make sure the data you are querying
doesn't contain non-serializable values, for example,
functions, DOM element handles, etc.

_Related_

- <https://pptr.dev/#?product=Puppeteer&version=v9.0.0&show=api-pageevaluatepagefunction-args>
- <https://github.com/WordPress/gutenberg/pull/31199>

_Parameters_

- _store_ `string`: Store to query e.g: core/editor, core/blocks...
Expand Down
11 changes: 11 additions & 0 deletions packages/e2e-test-utils/src/wp-data-select.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
/**
* Queries the WordPress data module.
*
* `page.evaluate` - used in the function - returns `undefined`
* when it encounters a non-serializable value.
* Since we store many different values in the data module,
* you can end up with an `undefined` result. Before using
* this function, make sure the data you are querying
* doesn't contain non-serializable values, for example,
* functions, DOM element handles, etc.
*
* @see https://pptr.dev/#?product=Puppeteer&version=v9.0.0&show=api-pageevaluatepagefunction-args
* @see https://github.com/WordPress/gutenberg/pull/31199
*
* @param {string} store Store to query e.g: core/editor, core/blocks...
* @param {string} selector Selector to exectute e.g: getBlocks.
* @param {...Object} parameters Parameters to pass to the selector.
Expand Down

0 comments on commit ab2a61a

Please sign in to comment.