Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
@wordpress/e2e-test-utils
Advanced tools
End-To-End (E2E) test utils for WordPress.
It works properly with the minimum version of Gutenberg 13.8.0
or the minimum version of WordPress 6.0.0
.
Note that there's currently an ongoing project to migrate E2E tests to Playwright instead. This package is deprecated and will only accept bug fixes until fully migrated.
Install the module
npm install @wordpress/e2e-test-utils --save-dev
Note: This package requires Node.js 14.0.0 or later. It is not compatible with older versions.
Activates an installed plugin.
Parameters
string
: Plugin slug.Activates an installed theme.
Parameters
string
: Theme slug.Verifies if publish checks are enabled.
Returns
Promise<boolean>
: Boolean which represents the state of prepublish checks.Gets the editor canvas frame.
Visits general settings page and changes the timezone to the given value.
Parameters
string
: Value of the timezone to set.Returns
string
: Value of the previous timezone.Clears the local storage.
Clicks the default block appender.
Clicks a block toolbar button.
Parameters
string
: The text string of the button label.[string]
: The type of button label: 'ariaLabel' or 'content'.Clicks a button based on the text on the button.
Parameters
string
: The text that appears on the button to click.Searches for an item in the menu with the text provided and clicks it.
Parameters
string
: The label to search the menu item for.Click on the close button of an open modal.
Parameters
?string
: Class name for the modal to closeClicks on More Menu item, searches for the button with the text provided and clicks it.
Parameters
string
: The label to search the button for.Closes the global inserter.
Closes list view
Creates a function to determine if a request is embedding a certain URL.
Parameters
string
: The URL to check against a request.Returns
Function
: Function that determines if a request is for the embed API, embedding a specific URL.Respond to a request with a JSON response.
Parameters
string
: The mock object to wrap in a JSON response.Returns
Promise
: Promise that responds to a request with the mock JSON response.Create menus and all linked resources for the menu using the REST API.
Parameters
Object
: Rest payload for the menu?Array
: Data for any menu items to be created.Creates new post.
Parameters
Object
: Object to create new post, along with tips enabling option.[string]
: Post type of the new post.[string]
: Title of the new post.[string]
: Content of the new post.[string]
: Excerpt of the new post.[boolean]
: Whether to show the welcome guide.Opens the template editor with a newly created template.
Parameters
string
: Name of the template.Creates a simple reusable block with a paragraph block.
Parameters
string
: Paragraph block's contenttitle
: Reusable block's name.Creates new URL by parsing base URL, WPPath and query string.
Parameters
string
: String to be serialized as pathname.?string
: String to be serialized as query portion of URL.Returns
string
: String which represents full URL.Creates a function to determine if a request is calling a URL with the substring present.
Parameters
string
: The substring to check for.Returns
Function
: Function that determines if a request's URL contains substring.Create a new user account.
Parameters
string
: User name.Object?
: Optional Settings for the new user account.[string]
: First name.[string]
: Last name.[string]
: Role. Defaults to Administrator.Returns
string
: Password for the newly created user account.Deactivates an active plugin.
Parameters
string
: Plugin slug.Delete all menus using the REST API
Delete all the templates of given type.
Parameters
('wp_template'|'wp_template_part')
: - Template type to delete.Delete all the widgets in the widgets screen.
Deletes a theme from the site, activating another theme if necessary.
Parameters
string
: Theme slug.Object?
: Optional settings object.string?
: A theme to switch to if the theme to delete is active. Required if the theme to delete is active.string?
: A search term to use if the new theme is not findable by its slug.Delete a user account.
Parameters
string
: User name.Removes the focus loss listener that enableFocusLossObservation()
adds.
Disable auto-accepting any dialogs.
Disables Pre-publish checks.
Skips the welcome guide popping up to first time users of the site editor
Clicks an element, drags a particular distance and releases the mouse button.
Parameters
Object
: The puppeteer element handle.Object
: Object containing movement distances.number
: Horizontal distance to drag.number
: Vertical distance to drag.Returns
Promise
: Promise resolving when drag completes.Adds an event listener to the document which throws an error if there is a loss of focus.
Enables event listener which auto-accepts all dialogs on the page.
Enables Pre-publish checks.
Verifies that the edit post/site/widgets sidebar is opened, and if it is not, opens it.
Returns
Promise
: Promise resolving once the sidebar is opened.Enters edit mode.
Finds a sidebar panel with the provided title.
Parameters
string
: The name of sidebar panel.Returns
?ElementHandle
: Object that represents an in-page DOM element.Finds the button responsible for toggling the sidebar panel with the provided title.
Parameters
string
: The name of sidebar panel.Returns
Promise<ElementHandle|undefined>
: Object that represents an in-page DOM element.Returns an array of strings with all inserter item titles.
Returns
Promise
: Promise resolving with an array containing all inserter item titles.Returns an array with all blocks; Equivalent to calling wp.data.select( 'core/block-editor' ).getBlocks();
Returns
Promise
: Promise resolving with an array containing all blocks in the document.Returns an array of strings with all block titles, that the current selected block can be transformed into.
Returns
Promise
: Promise resolving with an array containing all possible block transformsReturns a string containing the block title associated with the provided block name.
Parameters
string
: Block name.string
: Block setting e.g: title, attributes....Returns
Promise
: Promise resolving with a string containing the block title.Returns a promise which resolves with the current post content (HTML string).
Returns
Promise
: Promise resolving with current post content markup.Returns a promise which resolves with the edited post content (HTML string).
Returns
Promise<string>
: Promise resolving with post content markup.Returns a promise which resolves with the edited post content (HTML string).
Returns
Promise
: Promise resolving with post content markup.Gets all block anchor nodes in the list view that match a given block name label.
Parameters
string
: the label of the block as displayed in the ListView.Returns
Promise
: all the blocks anchor nodes matching the lable in the ListView.Returns a site option, from the options admin page.
Parameters
string
: The option, used to get the option by id.Returns
string
: The value of the option.Returns a promise resolving to one of either a string or null. A string will be resolved if an error message is present in the contents of the page. If no error is present, a null value will be resolved instead. This requires the environment be configured to display errors.
Related
Returns
Promise<?string>
: Promise resolving to a string or null, depending whether a page error is present.Returns a boolean indicating if the current selected block has a block switcher or not.
Returns
Promise
: Promise resolving with a boolean.Inserts a block matching a given search term via the global inserter.
Parameters
string
: The term by which to find the block to insert.Inserts a Block Directory block matching a given search term via the global inserter.
Parameters
string
: The term by which to find the Block Directory block to insert.Inserts a pattern matching a given search term via the global inserter.
Parameters
string
: The term by which to find the pattern to insert.Inserts a reusable block matching a given search term via the global inserter.
Parameters
string
: The term by which to find the reusable block to insert.Installs a plugin from the WP.org repository.
Parameters
string
: Plugin slug.string?
: If the plugin is not findable by its slug use an alternative term to search.Installs a theme from the WP.org repository.
Parameters
string
: Theme slug.Object?
: Optional settings object.string?
: Search term to use if the theme is not findable by its slug.Checks if current URL is a WordPress path.
Parameters
string
: String to be serialized as pathname.?string
: String to be serialized as query portion of URL.Returns
boolean
: Boolean represents whether current URL is or not a WordPress path.Checks if the block that is focused is the default block.
Returns
Promise
: Promise resolving with a boolean indicating if the focused block is the default block.Undocumented declaration.
Undocumented declaration.
Checks whether a theme exists on the site.
Parameters
string
: Theme slug to check.Returns
boolean
: Whether the theme exists.Performs log in with specified username and password.
Parameters
?string
: String to be used as user credential.?string
: String to be used as user credential.Performs log out.
Mocks a request with the supplied mock object, or allows it to run with an optional transform, based on the deserialised JSON response for the request.
Parameters
Function
: function that returns true if the request should be mocked.Object
: A mock object to wrap in a JSON response, if the request should be mocked.Function|undefined
: An optional function that transforms the response's object before the response is used.Returns
Promise
: Promise that uses mockCheck
to see if a request should be mocked with mock
, and optionally transforms the response with responseObjectTransform
.Clicks on the button in the header which opens Document Settings sidebar when it is closed.
Opens the global inserter.
Opens a global styles panel.
Parameters
string
: Name of the panel that is going to be opened.Opens list view
Opens the preview page of an edited post.
Parameters
Page
: puppeteer editor page.Returns
Page
: preview page.Opens the previous global styles panel.
Opens the publish panel.
Opens the Typography tools panel menu provided via block supports.
Presses the given keyboard key a number of times in sequence.
Parameters
string
: Key to press.number
: Number of times to press.Performs a key press with modifier (Shift, Control, Meta, Alt), where each modifier is normalized to platform-specific modifier.
Parameters
string
: Modifier key.string
: Key to press while modifier held.Publishes the post, resolving once the request is complete (once a notice is displayed).
Returns
Promise
: Promise resolving when publish is complete.Publishes the post without the pre-publish checks, resolving once the request is complete (once a notice is displayed).
Returns
Promise
: Promise resolving when publish is complete.Clears all user meta preferences.
Saves the post as a draft, resolving once the request is complete (once the "Saved" indicator is displayed).
Returns
Promise
: Promise resolving when draft save is complete.Searches for a block via the global inserter.
Parameters
string
: The term to search the inserter for.Returns
Promise<ElementHandle|null>
: The handle of block to be inserted or null if nothing was found.Searches for a Block Directory block via the global inserter.
Parameters
string
: The term to search the inserter for.Returns
Promise<ElementHandle|null>
: The handle of the Block Directory block to be inserted or null if nothing was found.Searches for a pattern via the global inserter.
Parameters
string
: The term to search the inserter for.Returns
Promise<ElementHandle|null>
: The handle of the pattern to be inserted or null if nothing was found.Searches for a reusable block via the global inserter.
Parameters
string
: The term to search the inserter for.Returns
Promise<ElementHandle|null>
: The handle of the reusable block to be inserted or null if nothing was found.Given the clientId of a block, selects the block on the editor.
Parameters
string
: Identified of the block.Sets browser viewport to specified type.
Parameters
WPViewport
: Viewport name or dimensions object to assign.Sets the clipboard data that can be pasted with pressKeyWithModifier( 'primary', 'v' )
.
Parameters
Object
: Options.string
: Plain text to set.string
: HTML to set.Sets a site option, from the options-general admin page.
Parameters
string
: The option, used to get the option by id.string
: The value to set the option to.Returns
string
: The previous value of the option.Sets code editor content
Parameters
string
: New code editor content.Returns
Promise
: Promise resolving with an array containing all blocks in the document.Sets up mock checks and responses. Accepts a list of mock settings with the following properties:
match
: function to check if a request should be mocked.onRequestMatch
: async function to respond to the request.Usage
const MOCK_RESPONSES = [
{
match: isEmbedding( 'https://wordpress.org/gutenberg/handbook/' ),
onRequestMatch: JSONResponse( MOCK_BAD_WORDPRESS_RESPONSE ),
},
{
match: isEmbedding(
'https://wordpress.org/gutenberg/handbook/block-api/attributes/'
),
onRequestMatch: JSONResponse( MOCK_EMBED_WORDPRESS_SUCCESS_RESPONSE ),
},
];
setUpResponseMocking( MOCK_RESPONSES );
If none of the mock settings match the request, the request is allowed to continue.
Parameters
Array
: Array of mock settings.The block toolbar is not always visible while typing. Call this function to reveal it.
Clicks on the block inspector tab button with the supplied label and waits for the tab switch.
Parameters
string
: Aria label to find tab button by.Switches editor mode.
Parameters
string
: String editor mode.Switches the current user to the admin user (if the user running the test is not already the admin user).
Switches the current user to whichever user we should be running the tests as (if we're not already that user).
Toggles the global inserter.
Toggles the global styles sidebar (opens it if closed and closes it if open).
Toggles the More Menu.
Parameters
['open' | 'close']
: Whether it should wait for the menu to open or close. If undefined
it won't wait for anything.Undocumented declaration.
Toggles a preference option with the given tab label and the option label.
Parameters
string
: The preferences tab label to click.string
: The option label to search the button for.[boolean]
: If true, turns the option on. If false, off. If not provided, the option will be toggled.Converts editor's block type.
Parameters
string
: Block name.Navigates to the comments listing screen and bulk-trashes any comments which exist.
Returns
Promise
: Promise resolving once comments have been trashed.Navigates to the post listing screen and bulk-trashes any posts which exist.
Parameters
string
: - String slug for type of post to trash.string
: - String status of posts to trash.Returns
Promise
: Promise resolving once posts have been trashed.Uninstalls a plugin.
Parameters
string
: Plugin slug.Visits admin page; if user is not logged in then it logging in it first, then visits admin page.
Parameters
string
: String to be serialized as pathname.string
: String to be serialized as query portion of URL.Visits the Site Editor main page
By default, it also skips the welcome guide. The option can be disabled if need be.
Related
Parameters
string
: String to be serialized as query portion of URL.[boolean]
: Whether to skip the welcome guide as part of the navigation.Function that waits until the page viewport has the required dimensions. It is being used to address a problem where after using setViewport the execution may continue, without the new dimensions being applied. https://github.com/GoogleChrome/puppeteer/issues/1751
Parameters
number
: Width of the window.number
: Height of the window.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
Parameters
string
: Store to query e.g: core/editor, core/blocks...string
: Selector to exectute e.g: getBlocks....Object
: Parameters to pass to the selector.Returns
Promise<?Object>
: Result of querying.This is an individual package that's part of the Gutenberg project. The project is organized as a monorepo. It's made up of multiple self-contained software packages, each with a specific purpose. The packages in this monorepo are published to npm and used by WordPress as well as other software projects.
To find out more about contributing to this package or Gutenberg as a whole, please read the project's main contributor guide.
FAQs
End-To-End (E2E) test utils for WordPress.
The npm package @wordpress/e2e-test-utils receives a total of 15,331 weekly downloads. As such, @wordpress/e2e-test-utils popularity was classified as popular.
We found that @wordpress/e2e-test-utils demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.