2

I am learning Behat with Drupal 8 and I'm stuck on trying to test a paragraph bundle (field_related_content) which has a title and description field, the title is an entity reference field to content type marine_notices. Currently I have the below, but the results are 'No link to Post Title', am I missing something?

  @api
  Scenario: Reference site pages from within a "marine_notices" node
  Given "marine_notices" content:
    | title      |
    | Post title  |
  When I am viewing a "marine_notices" content:
    | title                | Post title         |
    | field_related_content | Post title - <front> |
  Then I should see the link "Post title"
  • 1
    That won't work, paragraph is a too complex structure to just create it like that. What you need to do is either write a custom step definition that creates it, or since you also want to test the process of creating such a paragraph, you need to create the entity yourself, step by step. Log in as an editor with enough permissions, go to node/add/.., fill out all the fields you want and then save – Berdir Aug 31 '18 at 22:57
2

I needed something similar so I implemented a context for paragraph support.

Install using composer require miiimooo/behat-tools

The follow the installation and usage here: https://github.com/miiimooo/behat-tools

In your feature you can then write:

Feature: Content
  @api
  Scenario: Paragraph creation through Drupal 8 API

    Given a "my_paragraph_type" paragraph named "my_arbitrary_name":
      | title             | Lorem ipsum |

    Given I am viewing a "page" content:
      | title            | Dolor sed         |
      | field_paragraphs | my_arbitrary_name |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.