assign array of category to custom post type

Use the tax_input argument like this:

$categories = array(51,52,53,54,55);
$post_id = wp_insert_post( array(
        'post_content' => '',
        'post_name' => $title_slug,
        'post_title' => $title_slug,
        'post_status' => 'publish',
        'post_type' => 'test',
        'post_author' => 'me',
        'post_excerpt' => '',
    //  'post_date' => $date,
        'post_category' => $categories_id,
    //  'tags_input' => array($tags),
        'tax_input' => array(
                         'category' => $categories
                       );
    ));

Happy Coding 😉