diff --git a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestConstraintViolation.php b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestConstraintViolation.php
index e12c74a..b604b2c 100644
--- a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestConstraintViolation.php
+++ b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestConstraintViolation.php
@@ -3,6 +3,7 @@
 namespace Drupal\entity_test\Entity;
 
 use Drupal\Core\Entity\EntityTypeInterface;
+use Drupal\Core\Field\BaseFieldDefinition;
 
 /**
  * Defines the test entity class for testing entity constraint violations.
@@ -39,6 +40,16 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
     ]);
     $fields['name']->addConstraint('FieldWidgetConstraint', []);
 
+    // Add a field that uses a widget with a custom implementation for
+    // \Drupal\Core\Field\WidgetInterface::errorElement().
+    $fields['test_field'] = BaseFieldDefinition::create('test_field')
+      ->setLabel(t('Test field'))
+      ->setDisplayOptions('form', [
+        'type' => 'test_field_widget',
+        'weight' => 1,
+      ])
+      ->addConstraint('FieldWidgetConstraint', []);
+
     return $fields;
   }
 
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/FieldWidgetConstraintValidatorTest.php b/core/tests/Drupal/KernelTests/Core/Entity/FieldWidgetConstraintValidatorTest.php
index 041b062..c8efcc3 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/FieldWidgetConstraintValidatorTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/FieldWidgetConstraintValidatorTest.php
@@ -15,7 +15,7 @@
  */
 class FieldWidgetConstraintValidatorTest extends KernelTestBase {
 
-  public static $modules = ['entity_test', 'field', 'user', 'system'];
+  public static $modules = ['entity_test', 'field', 'field_test', 'user', 'system'];
 
   /**
    * {@inheritdoc}
@@ -55,6 +55,7 @@ public function testValidation() {
 
     $errors = $form_state->getErrors();
     $this->assertEqual($errors['name'], 'Widget constraint has failed.', 'Constraint violation is generated correctly');
+    $this->assertEqual($errors['test_field'], 'Widget constraint has failed.', 'Constraint violation is generated correctly for an advanced widget');
   }
 
   /**
