@10up/cypress-wp-utils
    Preparing search index...

    Function createPost

    • Create a Post

      Parameters

      • postData: {
            beforeSave?: CallableFunction;
            content?: string;
            postType?: string;
            status?: string;
            title: string;
        }

        Post data

      Returns void

      Wraps post data object. See WP_REST_Posts_Controller::prepare_item_for_response for the reference of post object contents: https://github.com/WordPress/WordPress/blob/master/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

      Create a Post and get ID

      cy.createPost({
      title: 'Test Post',
      content: 'Test Content'
      }).then(post => {
      const id = post.id;
      });

      Create a Post with draft status.

      cy.createPost({
      title: 'Test Post',
      content: 'Test Content',
      status: 'draft'
      })

      Create a Page

      cy.createPost({
      postType: 'page'
      title: 'Test page',
      content: 'Page Content'
      })

      Perform custom actions before saving the post

      cy.createPost({
      title: 'Post Title',
      beforeSave: () => {
      // Change additional metaboxes.
      }
      })