drupalCreateNode([ 'type' => 'article', 'promote' => NodeInterface::PROMOTED, ]); // Links are displayed by default. $this->drupalGet('node'); $this->assertSession()->pageTextContains($node->getTitle()); $this->assertSession()->linkExists('Read more'); // Hide links. \Drupal::service('entity_display.repository') ->getViewDisplay('node', 'article', 'teaser') ->removeComponent('links') ->save(); $this->drupalGet('node'); $this->assertSession()->pageTextContains($node->getTitle()); $this->assertSession()->linkNotExists('Read more'); } }