Kernel base test for media view displays is failing with: LogicException: Missing bundle entity, entity type media_type, entity id image I am trying to test media view displays via a test, which is based on the KernelTestBase class. I have also tried to inherit from Drupal\Tests\media\Kernel\MediaKernelTestBase, but got the same error from bellow:


  LogicException: Missing bundle entity, entity type media_type, entity
  id image.


My test class looks like this:

&lt;?php

namespace Drupal\Tests\degov_image_and_crop_styles\Kernel;

use Drupal\Core\Extension\ModuleHandler;
use Drupal\KernelTests\KernelTestBase;

class ModuleInstallationTest extends KernelTestBase {

  /**
   * {@inheritdoc}
   */
  public static $modules = [
    'user',
    'migrate',
    'migrate_drupal',
    'system',
    'node',
    'taxonomy',
    'field',
    'file',
    'image',
    'media',
    'media_test_source',
    'text',
    'filter',
    'language',
    'content_translation',
    'image_widget_crop',
    'crop',
    'lightning_core',
    'responsive_image',
    'breakpoint',
    'degov_image_and_crop_styles',
  ];

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::setUp();
    $this-&gt;installEntitySchema('node');
    $this-&gt;installEntitySchema('file');
    $this-&gt;installEntitySchema('media');
    $this-&gt;installEntitySchema('taxonomy_term');
    $this-&gt;installEntitySchema('taxonomy_vocabulary');
    $this-&gt;installEntitySchema('user');
    $this-&gt;installSchema('system', ['sequences']);
    $this-&gt;installSchema('user', 'users_data');
    $this-&gt;installSchema('file', 'file_usage');
    $this-&gt;installSchema('node', ['node_access']);
    $this-&gt;installConfig(self::$modules);
  }

  public function testSetup(): void {
    /**
     * @var ModuleHandler $moduleHandler
     */
    $moduleHandler = \Drupal::service('module_handler');
    self::assertTrue($moduleHandler-&gt;moduleExists('degov_image_and_crop_styles'));
    self::assertTrue($moduleHandler-&gt;getModule('degov_image_and_crop_styles'));
  }

}


Does anyone know, what I am missing here?
I could solve this via:

$this->createMediaType('image');

Also I inherited from MediaKernelTestBase.