diff --git a/config/schema/select2boxes.schema.yml b/config/schema/select2boxes.schema.yml
index 7c2d256..0802e1d 100644
--- a/config/schema/select2boxes.schema.yml
+++ b/config/schema/select2boxes.schema.yml
@@ -11,3 +11,26 @@ select2boxes.settings:
     url:
       type: string
       label: 'CDN URL'
+
+field.widget.third_party.select2boxes:
+  type: mapping
+  label: 'Third party settings of Select2Boxes'
+  mapping:
+    enable_preload:
+      type: string
+      label: 'Enable preload'
+    preload_count:
+      type: string
+      label: 'Preload count'
+    enable_flags:
+      type: string
+      label: 'Include flags icons'
+    limited_search:
+      type: string
+      label: 'Limit search box visibility by list length'
+    minimum_search_length:
+      type: string
+      label: 'Minimum list length'
+    enable_select2:
+      type: string
+      label: 'Enable Select2 widget for dropdowns'
diff --git a/modules/select2_bef/tests/src/FunctionalJavascript/Select2BefTests.php b/modules/select2_bef/tests/src/FunctionalJavascript/Select2BefTests.php
new file mode 100644
index 0000000..cf07815
--- /dev/null
+++ b/modules/select2_bef/tests/src/FunctionalJavascript/Select2BefTests.php
@@ -0,0 +1,264 @@
+<?php
+
+namespace Drupal\Tests\select2_bef\FunctionalJavascript;
+
+use Drupal\Tests\select2boxes\FunctionalJavascript\Select2BoxesTestsBase;
+
+/**
+ * Class Select2BefTests.
+ *
+ * @package Drupal\Tests\select2_bef\FunctionalJavascript
+ *
+ * @group Select2Bef
+ */
+class Select2BefTests extends Select2BoxesTestsBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public static $modules = [
+    'select2boxes',
+    'select2_bef',
+    'better_exposed_filters',
+    'node',
+    'field',
+    'views',
+    'views_ui',
+  ];
+
+  /**
+   * Test if the BEF plugin is overridden successfully.
+   */
+  public function testBetterExposedFormPluginOverride() {
+    // Check if the plugin manager service exists.
+    $this->assertTrue(\Drupal::hasService('plugin.manager.views.exposed_form'));
+    /** @var \Drupal\Core\Field\WidgetPluginManager $plugin_manager */
+    $plugin_manager = \Drupal::service('plugin.manager.views.exposed_form');
+    // Check each plugin if it has definition under a plugin manager service.
+    $this->assertTrue($plugin_manager->hasDefinition('bef'));
+    $this->assertEquals(
+      'Drupal\select2_bef\Plugin\views\exposed_form\BetterExposedFilters',
+      $plugin_manager->getDefinition('bef')['class']
+    );
+  }
+
+  /**
+   * Test entity reference exposed filters.
+   */
+  public function testEntityReferenceFieldFilters() {
+    // Disable JS errors to prevent test failures
+    // due to the View's module JS console errors.
+    $this->minkSession->getDriver()->getBrowser()->jsErrors(FALSE);
+    // Generate fake contents for testing.
+    $this->generateDummyTerms('tags', 10);
+    $this->generateDummyArticles(10);
+
+    // Go to the view's creation page.
+    $this->drupalGet('admin/structure/views/add');
+    $this->assertEquals(200, $this->minkSession->getStatusCode());
+
+    // Fill all required fields and save the new view.
+    $this->minkSession->getPage()->fillField('label', 'Test');
+    $this->minkSession->wait(1000);
+    $this->minkSession->getPage()->fillField('id', 'test');
+    $this->minkSession->wait(1000);
+    $this->minkSession->getPage()->selectFieldOption('show[type]', 'article');
+    $this->minkSession->wait(5000);
+    $this->minkSession->getPage()->checkField('page[create]');
+    $this->minkSession->wait(1000);
+    $this->minkSession->getPage()->fillField('page[title]', 'Test');
+    $this->minkSession->getPage()->fillField('page[path]', 'test');
+    $this->minkSession->wait(1000);
+    $this->assertSession()->buttonExists('Save and edit')->click();
+    $this->minkSession->wait(20000);
+    $this->assertEquals(200, $this->minkSession->getStatusCode());
+    $this->assertSession()->addressEquals('admin/structure/views/view/test');
+    $this->assertTextHelper('The view Test has been saved', FALSE);
+
+    // Add filter by field "Tags" using the View's UI.
+    $this->click('a[id="views-add-filter"]');
+    $this->minkSession->wait(2000);
+    $this->minkSession->getPage()->fillField('override[controls][options_search]', 'tags');
+    $this->minkSession->getPage()->checkField('name[node__field_tags.field_tags_target_id]');
+    $this->assertTextHelper('Selected: Tags (field_tags)', FALSE);
+    $this->click('button.button--primary');
+    $this->minkSession->wait(2000);
+
+    // Set dropdown as a filter widget.
+    $this->minkSession->getPage()->fillField('options[type]', 'select');
+    $this->click('button.button--primary');
+    $this->minkSession->wait(2000);
+    $this->assertTextHelper('Configure filter criterion: Content: Tags (field_tags)', FALSE);
+
+    // Make filter exposed.
+    $this->minkSession->getPage()->checkField('options[expose_button][checkbox][checkbox]');
+    $this->minkSession->wait(2000);
+    $this->click('button.button--primary');
+    $this->minkSession->wait(5000);
+    // Save the view.
+    $this->saveForm();
+    $this->minkSession->wait(5000);
+    $this->assertTextHelper('Content: Tags (exposed)', FALSE);
+
+    $this->click('summary[role="button"]');
+    $this->minkSession->wait(2000);
+    $this->click('a[id="views-page-1-exposed-form"]');
+    $this->minkSession->wait(2000);
+    $this->minkSession->getPage()->fillField('exposed_form[type]', 'bef');
+    $this->click('button.button--primary');
+    $this->minkSession->wait(1000);
+    // Check for existing options.
+    $dropdown = $this->minkSession
+      ->getPage()
+      ->find('xpath', '//select[@name="exposed_form_options[bef][field_tags_target_id][bef_format]"]');
+    $this->assertNotNull($dropdown);
+    $options = $this->getFieldOptions($dropdown);
+    $this->assertContains('select2boxes_autocomplete_multi', $options);
+    $this->assertContains('select2boxes_autocomplete_single', $options);
+    $this->minkSession
+      ->getPage()
+      ->selectFieldOption('exposed_form_options[bef][field_tags_target_id][bef_format]', 'select2boxes_autocomplete_single');
+    $this->minkSession->wait(1000);
+    $bundles_element = $this->minkSession
+      ->getPage()
+      ->find('xpath', '//input[@name="exposed_form_options[bef][field_tags_target_id][more_options][reference_bundles][tags]"]');
+    $this->assertNotNull($bundles_element);
+    $this->minkSession
+      ->getPage()
+      ->checkField('exposed_form_options[bef][field_tags_target_id][more_options][reference_bundles][tags]');
+    $this->minkSession->wait(1000);
+    $this->click('button.button--primary');
+    $this->minkSession->wait(2000);
+    $this->saveForm();
+    $this->minkSession->wait(5000);
+    $this->drupalGet('test');
+    $this->assertEquals(200, $this->minkSession->getStatusCode());
+    $select = $this->getFieldById('edit-field-tags-target-id');
+    $this->assertNotNull($select);
+    // Check if all required html attributes are exist
+    // for the entity reference field.
+    $this->assertNotNull($select->getAttribute('data-jquery-once-autocomplete'));
+    $this->assertNotNull($select->getAttribute('data-select2-autocomplete-list-widget'));
+    $this->assertTrue($select->hasClass('select2-widget'));
+
+    // Update widget to use multiple Select2 widget.
+    $this->drupalGet('admin/structure/views/view/test');
+    $this->assertEquals(200, $this->minkSession->getStatusCode());
+
+    $this->clickLink('Content: Tags (exposed)');
+    $this->minkSession->wait(2000);
+    $this->minkSession->getPage()->checkField('options[expose][multiple]');
+    $this->click('button.button--primary');
+    $this->minkSession->wait(2000);
+
+    $this->drupalGet('admin/structure/views/nojs/display/test/page_1/exposed_form_options');
+    $this->assertEquals(200, $this->minkSession->getStatusCode());
+
+
+    $edit = [
+      'exposed_form_options[bef][field_tags_target_id][bef_format]' => 'select2boxes_autocomplete_multi',
+      'exposed_form_options[bef][field_tags_target_id][more_options][reference_bundles][tags]' => '1',
+      'exposed_form_options[bef][field_tags_target_id][more_options][enable_preload]' => '1',
+      'exposed_form_options[bef][field_tags_target_id][more_options][preload_count]' => '5',
+    ];
+    $this->submitForm($edit, t('Apply'));
+    $this->minkSession->wait(5000);
+    $this->saveForm();
+    $this->minkSession->wait(5000);
+    $this->drupalGet('test');
+    $this->assertEquals(200, $this->minkSession->getStatusCode());
+    // Trigger the opening dropdown via click on the search input field.
+    $this->click('input[class="select2-search__field"]');
+    $this->minkSession->wait(1000);
+    $select = $this->getFieldById('edit-field-tags-target-id');
+    $this->assertNotNull($select);
+    // Check if all required html attributes are exist
+    // for the entity reference field.
+    $this->assertNotNull($select->getAttribute('data-jquery-once-autocomplete'));
+    $this->assertNotNull($select->getAttribute('data-select2-multiple'));
+    $this->assertNotNull($select->getAttribute('data-autocomplete-path'));
+    $this->assertNotNull($select->getAttribute('data-field-name'));
+    $this->assertTrue($select->hasClass('select2-widget'));
+    $this->assertTrue($select->hasClass('select2-boxes-widget'));
+    // Check if the number of results is equals to the 5 rows
+    // (as was specified in the widget settings).
+    $this->assertEquals(5, count($this->getFieldById('select2-edit-field-tags-target-id-results')->findAll('xpath', '//li')));
+  }
+
+  /**
+   * Test list exposed filters.
+   */
+  public function testListExposedFilters() {
+    // Disable JS errors to prevent test failures
+    // due to the View's module JS console errors.
+    $this->minkSession->getDriver()->getBrowser()->jsErrors(FALSE);
+    // Generate fake contents for testing.
+    $this->generateDummyTerms('tags', 10);
+    $this->generateDummyArticles(10);
+    // Go to the view's creation page.
+    $this->drupalGet('admin/structure/views/add');
+    $this->assertEquals(200, $this->minkSession->getStatusCode());
+
+    // Fill all required fields and save the new view.
+    $this->minkSession->getPage()->fillField('label', 'Test');
+    $this->minkSession->wait(1000);
+    $this->minkSession->getPage()->fillField('id', 'test');
+    $this->minkSession->wait(1000);
+    $this->minkSession->getPage()->selectFieldOption('show[type]', 'article');
+    $this->minkSession->wait(5000);
+    $this->minkSession->getPage()->checkField('page[create]');
+    $this->minkSession->wait(1000);
+    $this->minkSession->getPage()->fillField('page[title]', 'Test');
+    $this->minkSession->getPage()->fillField('page[path]', 'test');
+    $this->minkSession->wait(1000);
+    $this->assertSession()->buttonExists('Save and edit')->click();
+    $this->minkSession->wait(20000);
+    $this->assertEquals(200, $this->minkSession->getStatusCode());
+    $this->assertSession()->addressEquals('admin/structure/views/view/test');
+    $this->assertTextHelper('The view Test has been saved', FALSE);
+
+    // Add filter by field "Tags" using the View's UI.
+    $this->click('a[id="views-add-filter"]');
+    $this->minkSession->wait(2000);
+    $this->minkSession->getPage()->fillField('override[controls][options_search]', 'Test');
+    $this->minkSession->getPage()->checkField('name[node__field_test_list.field_test_list_value]');
+    $this->click('button.button--primary');
+    $this->minkSession->wait(2000);
+
+    // Make filter exposed.
+    $this->minkSession->getPage()->checkField('options[expose_button][checkbox][checkbox]');
+    $this->minkSession->wait(2000);
+    $this->click('button.button--primary');
+    $this->minkSession->wait(5000);
+
+
+    $this->drupalGet('admin/structure/views/nojs/display/test/page_1/exposed_form');
+    $this->assertEquals(200, $this->minkSession->getStatusCode());
+    $edit = [
+      'exposed_form[type]' => 'bef',
+    ];
+    $this->submitForm($edit, t('Apply'));
+    $this->minkSession->wait(5000);
+    $this->drupalGet('admin/structure/views/nojs/display/test/page_1/exposed_form_options');
+    $this->assertEquals(200, $this->minkSession->getStatusCode());
+    $edit = [
+      'exposed_form_options[bef][field_test_list_value][bef_format]' => 'select2boxes_autocomplete_list',
+    ];
+    $this->submitForm($edit, t('Apply'));
+    $this->minkSession->wait(5000);
+    $this->saveForm();
+    $this->minkSession->wait(5000);
+
+    $this->drupalGet('test');
+    $this->assertEquals(200, $this->minkSession->getStatusCode());
+
+    $select = $this->getFieldById('edit-field-test-list-value');
+    $this->assertNotNull($select);
+    // Check if all required html attributes are exist
+    // for the entity reference field.
+    $this->assertNotNull($select->getAttribute('data-jquery-once-autocomplete'));
+    $this->assertNotNull($select->getAttribute('data-select2-autocomplete-list-widget'));
+    $this->assertTrue($select->hasClass('select2-widget'));
+  }
+
+}
diff --git a/select2boxes.module b/select2boxes.module
index 46f38ea..e725853 100644
--- a/select2boxes.module
+++ b/select2boxes.module
@@ -68,7 +68,7 @@ function select2boxes_field_widget_third_party_settings_form(WidgetInterface $pl
     $element['enable_preload'] = [
       '#type'          => 'checkbox',
       '#title'         => t('Enable pre-loaded entries'),
-      '#default_value' => $settings['enable_preload'] == '1',
+      '#default_value' => isset($settings['enable_preload']) && $settings['enable_preload'] == '1',
     ];
     $field_name = $field_definition->getName();
     $element['preload_count'] = [
@@ -100,7 +100,7 @@ function select2boxes_field_widget_third_party_settings_form(WidgetInterface $pl
       $element['enable_flags'] = [
         '#type'          => 'checkbox',
         '#title'         => t('Include flags icons'),
-        '#default_value' => $settings['enable_flags'] == '1',
+        '#default_value' => isset($settings['enable_flags']) && $settings['enable_flags'] == '1',
       ];
     }
 
@@ -108,7 +108,7 @@ function select2boxes_field_widget_third_party_settings_form(WidgetInterface $pl
     $element['limited_search'] = [
       '#type'          => 'checkbox',
       '#title'         => t('Limit search box visibility by list length'),
-      '#default_value' => $settings['limited_search'] == '1',
+      '#default_value' => isset($settings['limited_search']) && $settings['limited_search'] == '1',
     ];
     $field_name = $field_definition->getName();
     $element['minimum_search_length'] = [
@@ -130,7 +130,7 @@ function select2boxes_field_widget_third_party_settings_form(WidgetInterface $pl
     $element['enable_select2'] = [
       '#type'          => 'checkbox',
       '#title'         => t('Enable Select2 widget for dropdowns'),
-      '#default_value' => $settings['enable_select2'] == '1',
+      '#default_value' => isset($settings['enable_select2']) && $settings['enable_select2'] == '1',
     ];
     return $element;
   }
diff --git a/src/Plugin/Field/FieldWidget/MultiSelect2BoxesAutocompleteWidget.php b/src/Plugin/Field/FieldWidget/MultiSelect2BoxesAutocompleteWidget.php
index 748763d..6272d10 100644
--- a/src/Plugin/Field/FieldWidget/MultiSelect2BoxesAutocompleteWidget.php
+++ b/src/Plugin/Field/FieldWidget/MultiSelect2BoxesAutocompleteWidget.php
@@ -85,7 +85,7 @@ class MultiSelect2BoxesAutocompleteWidget extends OptionsSelectWidget {
     $element['#attached']['library'][] = 'select2boxes/widget';
     // Get third party settings.
     $settings = $this->getThirdPartySettings('select2boxes');
-    if ($settings['enable_preload'] == '1') {
+    if (isset($settings['enable_preload']) && $settings['enable_preload'] == '1') {
       $this->attachPreload(
         $element['#attached'],
         $settings['preload_count'],
diff --git a/tests/src/FunctionalJavascript/Select2BoxesTests.php b/tests/src/FunctionalJavascript/Select2BoxesTests.php
new file mode 100644
index 0000000..ef76c32
--- /dev/null
+++ b/tests/src/FunctionalJavascript/Select2BoxesTests.php
@@ -0,0 +1,293 @@
+<?php
+
+namespace Drupal\Tests\select2boxes\FunctionalJavascript;
+
+/**
+ * Class Select2BoxesTests.
+ *
+ * @package Drupal\Tests\select2boxes\FunctionalJavascript
+ * @group Select2Boxes
+ */
+class Select2BoxesTests extends Select2BoxesTestsBase {
+
+  /**
+   * Tests whether the widgets plugins are exist and accessible.
+   */
+  public function testWidgetsPlugins() {
+    // Check if the plugin manager service exists.
+    $this->assertTrue(\Drupal::hasService('plugin.manager.field.widget'));
+    /** @var \Drupal\Core\Field\WidgetPluginManager $plugin_manager */
+    $plugin_manager = \Drupal::service('plugin.manager.field.widget');
+    // Check each plugin if it has definition under a plugin manager service.
+    foreach (static::$pluginIds as $widget) {
+      $this->assertTrue($plugin_manager->hasDefinition($widget));
+    }
+  }
+
+  /**
+   * Check whether all widgets are exist in the field widgets settings.
+   */
+  public function testWidgetsAdminExistence() {
+    // Go the the "Manage Form Display" form.
+    $this->drupalGet(static::$manageFormDisplayPath);
+    $this->assertSession()->statusCodeEquals(200);
+
+    // Check for entity reference field widgets.
+    $select = $this->getFieldById('edit-fields-field-tags-type');
+    $options = $this->getFieldOptions($select);
+    $this->assertNotEmpty($options);
+    $this->assertContains(static::$pluginIds[1], $options);
+    $this->assertContains(static::$pluginIds[2], $options);
+
+    // Check if the newly created field is exist in the list.
+    $select = $this->getFieldById('edit-fields-field-test-list-type');
+    $this->assertNotNull($select);
+    // Check for list field widgets.
+    $options = $this->getFieldOptions($select);
+    $this->assertNotEmpty($options);
+    $this->assertContains(static::$pluginIds[0], $options);
+
+
+    // Set the Select2Boxes widgets for both fields and submit the form.
+    $this->minkSession
+      ->getPage()
+      ->find('xpath', '//select[@name="fields[field_test_list][type]"]')
+      ->setValue(static::$pluginIds[0]);
+    $this->minkSession->wait(2000);
+    $this->minkSession
+      ->getPage()
+      ->find('xpath', '//select[@name="fields[field_tags][type]"]')
+      ->setValue(static::$pluginIds[1]);
+    $this->minkSession->wait(2000);
+    $this->saveForm();
+    // Check if the submission is finishing correctly.
+    $this->assertSession()->statusCodeEquals(200);
+  }
+
+  /**
+   * Test single widget for entity reference fields.
+   */
+  public function testSingleWidget() {
+    // Go the the "Manage Form Display" form.
+    $this->drupalGet(static::$manageFormDisplayPath);
+    $this->assertSession()->statusCodeEquals(200);
+    // Set single widget for the Tags field.
+    $this->minkSession
+      ->getPage()
+      ->find('xpath', '//select[@name="fields[field_tags][type]"]')
+      ->setValue(static::$pluginIds[1]);
+    $this->minkSession->wait(2000);
+    $this->saveForm();
+    $this->assertSession()->statusCodeEquals(200);
+    // Now let's check the widgets style on a node creation page.
+    $this->drupalGet(static::$nodeAddPath);
+    $this->assertSession()->statusCodeEquals(200);
+    $select = $this->getFieldById('edit-field-tags');
+    $this->assertNotNull($select);
+    // Check if all required html attributes are exist
+    // for the entity reference field.
+    $this->assertNotNull($select->getAttribute('data-jquery-once-autocomplete'));
+    $this->assertNotNull($select->getAttribute('data-select2-autocomplete-list-widget'));
+    $this->assertTrue($select->hasClass('select2-widget'));
+  }
+
+  /**
+   * Test multiple widget for entity reference fields.
+   */
+  public function testMultipleWidget() {
+    // Go the the "Manage Form Display" form.
+    $this->drupalGet(static::$manageFormDisplayPath);
+    $this->assertSession()->statusCodeEquals(200);
+    // Set multiple widget for the Tags field.
+    $this->minkSession
+      ->getPage()
+      ->find('xpath', '//select[@name="fields[field_tags][type]"]')
+      ->setValue(static::$pluginIds[2]);
+    $this->minkSession->wait(2000);
+    $this->saveForm();
+    $this->assertSession()->statusCodeEquals(200);
+    // Now let's check the node creation page.
+    $this->drupalGet(static::$nodeAddPath);
+    $this->assertSession()->statusCodeEquals(200);
+    $select = $this->getFieldById('edit-field-tags');
+    $this->assertNotNull($select);
+    // Check if all required html attributes are exist
+    // for the entity reference field.
+    $this->assertNotNull($select->getAttribute('data-jquery-once-autocomplete'));
+    $this->assertNotNull($select->getAttribute('data-select2-multiple'));
+    $this->assertNotNull($select->getAttribute('data-autocomplete-path'));
+    $this->assertNotNull($select->getAttribute('data-field-name'));
+    $this->assertTrue($select->hasClass('select2-widget'));
+    $this->assertTrue($select->hasClass('select2-boxes-widget'));
+  }
+
+  /**
+   * Test widget for a list type of fields.
+   */
+  public function testListWidget() {
+    // Go the the "Manage Form Display" form.
+    $this->drupalGet(static::$manageFormDisplayPath);
+    $this->assertSession()->statusCodeEquals(200);
+    // Set list widget for the Test list field.
+    $this->minkSession
+      ->getPage()
+      ->find('xpath', '//select[@name="fields[field_test_list][type]"]')
+      ->setValue(static::$pluginIds[0]);
+    $this->minkSession->wait(2000);
+    $this->saveForm();
+    $this->assertSession()->statusCodeEquals(200);
+    // Now let's check the node creation page.
+    $this->drupalGet(static::$nodeAddPath);
+    $this->assertSession()->statusCodeEquals(200);
+    $select = $this->getFieldById('edit-field-test-list');
+    $this->assertNotNull($select);
+    // Check if all required html attributes are exist
+    // for the list field.
+    $this->assertNotNull($select->getAttribute('data-jquery-once-autocomplete'));
+    $this->assertNotNull($select->getAttribute('data-select2-autocomplete-list-widget'));
+    $this->assertTrue($select->hasClass('select2-widget'));
+  }
+
+  /**
+   * Test preloading functionality for the multiple entity reference widgets.
+   */
+  public function testPreloading() {
+    // Firstly generate a fake content.
+    $this->generateDummyTerms('tags', 10);
+    // Go the the "Manage Form Display" form.
+    $this->drupalGet(static::$manageFormDisplayPath);
+    $this->assertSession()->statusCodeEquals(200);
+    // Set multiple widget for the Tags field.
+    $this->minkSession
+      ->getPage()
+      ->find('xpath', '//select[@name="fields[field_tags][type]"]')
+      ->setValue(static::$pluginIds[2]);
+    $this->minkSession->wait(2000);
+    // Check for the summary text about preloading option.
+    $this->assertTextHelper('Preloading disabled', FALSE);
+    // Open the settings form for the Tags field.
+    $this->click('input[name="field_tags_settings_edit"]');
+    $this->minkSession->wait(2000);
+    // Enable preloading via checking the checkbox field.
+    $this->minkSession
+      ->getPage()
+      ->checkField('fields[field_tags][settings_edit_form][third_party_settings][select2boxes][enable_preload]');
+    $this->minkSession->wait(500);
+    // Set 5 rows to be preloaded.
+    $this->minkSession
+      ->getPage()
+      ->fillField('fields[field_tags][settings_edit_form][third_party_settings][select2boxes][preload_count]', '5');
+    // Submit the settings form.
+    $this->click('input[name="field_tags_plugin_settings_update"]');
+    $this->minkSession->wait(2000);
+    // Check for summary text updates.
+    $this->assertTextHelper('Preloading enabled', FALSE);
+    $this->assertTextHelper('Number of preloaded entries: 5', FALSE);
+    // Submit the entity form display settings.
+    $this->saveForm();
+    $this->minkSession->wait(2000);
+    $this->assertSession()->statusCodeEquals(200);
+    // Go to the node's creation form.
+    $this->drupalGet(static::$nodeAddPath);
+    $this->assertSession()->statusCodeEquals(200);
+
+    // Trigger the opening dropdown via click on the search input field.
+    $this->click('input[class="select2-search__field"]');
+    $this->minkSession->wait(1000);
+    // Find the list of results element on the page.
+    $select = $this->getFieldById('select2-edit-field-tags-results');
+    $this->assertNotNull($select);
+    // Check if the number of results is equals to the 5 rows
+    // (as was specified in the widget settings).
+    $this->assertEquals(5, count($select->findAll('xpath', '//li')));
+  }
+
+  /**
+   * Test limited search option functionality.
+   */
+  public function testLimitedSearch() {
+    // Go the the "Manage Form Display" form.
+    $this->drupalGet(static::$manageFormDisplayPath);
+    $this->assertSession()->statusCodeEquals(200);
+
+    // Set list widget for the Test list field.
+    $this->minkSession
+      ->getPage()
+      ->find('xpath', '//select[@name="fields[field_test_list][type]"]')
+      ->setValue(static::$pluginIds[0]);
+    $this->minkSession->wait(2000);
+
+    // Open the settings form for the List field.
+    $this->click('input[name="field_test_list_settings_edit"]');
+    $this->minkSession->wait(2000);
+
+    // Enable limited search option.
+    $this->minkSession
+      ->getPage()
+      ->checkField('fields[field_test_list][settings_edit_form][third_party_settings][select2boxes][limited_search]');
+    $this->minkSession->wait(500);
+    // Specify minimum length search to a BIGGER value
+    // than we have in our "Allowed values" settings for the field.
+    $this->minkSession
+      ->getPage()
+      ->fillField('fields[field_test_list][settings_edit_form][third_party_settings][select2boxes][minimum_search_length]', '4');
+    // Submit the settings form.
+    $this->click('input[name="field_test_list_plugin_settings_update"]');
+    $this->minkSession->wait(1000);
+    // Submit the entity form display settings.
+    $this->saveForm();
+    $this->minkSession->wait(2000);
+    $this->assertSession()->statusCodeEquals(200);
+    // Go to the node's creation form.
+    $this->drupalGet(static::$nodeAddPath);
+    $this->assertSession()->statusCodeEquals(200);
+
+    // Trigger opening dropdown.
+    $this->minkSession
+      ->getDriver()
+      ->executeScript("jQuery('select[name=\"field_test_list\"]').select2('open');");
+    // Check for NON-existing search input field.
+    $search_input = $this->minkSession
+      ->getPage()
+      ->find('xpath', '//span[contains(@class, \'select2-search--dropdown\')]');
+    $this->assertNotNull($search_input);
+    $this->assertTrue($search_input->hasClass('select2-search--hide'));
+
+    // Go back to the "Manage Form Display" form
+    // and change the min length to a value that fits minimum values count.
+    $this->drupalGet(static::$manageFormDisplayPath);
+    $this->assertSession()->statusCodeEquals(200);
+    // Open the settings form for the List field.
+    $this->click('input[name="field_test_list_settings_edit"]');
+    $this->minkSession->wait(2000);
+
+    // Specify minimum length search to the SAME value
+    // than we have in our "Allowed values" settings for the field.
+    $this->minkSession
+      ->getPage()
+      ->fillField('fields[field_test_list][settings_edit_form][third_party_settings][select2boxes][minimum_search_length]', '3');
+    // Submit the settings form.
+    $this->click('input[name="field_test_list_plugin_settings_update"]');
+    $this->minkSession->wait(1000);
+    // Submit the entity form display settings.
+    $this->saveForm();
+    $this->minkSession->wait(2000);
+    $this->assertSession()->statusCodeEquals(200);
+
+    // Go to the node's creation form.
+    $this->drupalGet(static::$nodeAddPath);
+    $this->assertSession()->statusCodeEquals(200);
+
+    // Trigger opening dropdown.
+    $this->minkSession
+      ->getDriver()
+      ->executeScript("jQuery('select[name=\"field_test_list\"]').select2('open');");
+    // Check for EXISTING search input field.
+    $search_input = $this->minkSession
+      ->getPage()
+      ->find('xpath', '//span[contains(@class, \'select2-search--dropdown\')]');
+    $this->assertNotNull($search_input);
+    $this->assertFalse($search_input->hasClass('select2-search--hide'));
+  }
+
+}
diff --git a/tests/src/FunctionalJavascript/Select2BoxesTestsBase.php b/tests/src/FunctionalJavascript/Select2BoxesTestsBase.php
new file mode 100644
index 0000000..936c107
--- /dev/null
+++ b/tests/src/FunctionalJavascript/Select2BoxesTestsBase.php
@@ -0,0 +1,222 @@
+<?php
+
+namespace Drupal\Tests\select2boxes\FunctionalJavascript;
+
+use Behat\Mink\Element\NodeElement;
+use Drupal\field_ui\Tests\FieldUiTestTrait;
+use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\node\Entity\Node;
+use Drupal\taxonomy\Entity\Term;
+
+/**
+ * Class Select2BoxesTestsBase.
+ *
+ * Base class for the Select2Boxes tests.
+ *
+ * @package Drupal\Tests\select2boxes\FunctionalJavascript
+ */
+class Select2BoxesTestsBase extends JavascriptTestBase {
+  use FieldUiTestTrait;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected $profile = 'standard';
+
+  /**
+   * Modules that needs to be enabled.
+   *
+   * @var array
+   */
+  protected static $modules = ['select2boxes', 'node', 'field'];
+
+  /**
+   * Plugin IDs list of the field widgets.
+   *
+   * @var array
+   */
+  protected static $pluginIds = [
+    'select2boxes_autocomplete_list',
+    'select2boxes_autocomplete_single',
+    'select2boxes_autocomplete_multi',
+  ];
+
+  /**
+   * Captures index.
+   *
+   * @var int
+   */
+  protected $capturesIndex = 0;
+
+  /**
+   * Manage form display path.
+   *
+   * @var string
+   */
+  protected static $manageFormDisplayPath = 'admin/structure/types/manage/article/form-display';
+
+  /**
+   * Node add form path.
+   *
+   * @var string
+   */
+  protected static $nodeAddPath = 'node/add/article';
+
+  /**
+   * The active Mink session object.
+   *
+   * @var \Behat\Mink\Session
+   */
+  protected $minkSession;
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setUp() {
+    parent::setUp();
+    $this->drupalLogin($this->createUser([], NULL, TRUE));
+    // Create list field.
+    $this->fieldUIAddNewField(
+      'admin/structure/types/manage/article',
+      'test_list',
+      'Test list',
+      'list_integer',
+      ['settings[allowed_values]' => '0|1' . PHP_EOL . '1|2' . PHP_EOL . '2|3']
+    );
+    $this->minkSession = $this->getSession();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function tearDown() {
+    // Destroy the testing kernel.
+    if (isset($this->kernel)) {
+      $this->cleanupEnvironment();
+      $this->kernel->shutdown();
+    }
+
+    // Ensure that internal logged in variable is reset.
+    $this->loggedInUser = FALSE;
+
+    if ($this->mink) {
+      $this->mink->stopSessions();
+    }
+
+    // Restore original shutdown callbacks.
+    if (function_exists('drupal_register_shutdown_function')) {
+      $callbacks = &drupal_register_shutdown_function();
+      $callbacks = $this->originalShutdownCallbacks;
+    }
+  }
+
+  /**
+   * Simply tests that site isn't broken after a module is being installed.
+   */
+  public function testModuleInstallation() {
+    // Go to the front page.
+    $this->drupalGet('<front>');
+    // Check if the response status is 200(OK).
+    $this->assertSession()->statusCodeEquals(200);
+  }
+
+  /**
+   * Get field options.
+   * 
+   * @param NodeElement $select
+   *   Field element.
+   *
+   * @return array
+   *   Options array.
+   */
+  protected function getFieldOptions(NodeElement $select) {
+    $options = [];
+    foreach ($select->findAll('xpath', '//option') as $option) {
+      /* @var NodeElement $option */
+      $options[] = $option->getAttribute('value') ?: $option->getText();
+    }
+    return $options;
+  }
+
+  /**
+   * Get field element by it's ID.
+   *
+   * @param string $id
+   *   Element's ID.
+   *
+   * @return \Behat\Mink\Element\NodeElement|null
+   *   Element object if found, NULL otherwise.
+   */
+  protected function getFieldById($id) {
+    return $this->minkSession
+      ->getPage()
+      ->findById($id);
+  }
+
+  /**
+   * Generates a specified number of terms within a specific vocabulary.
+   *
+   * @param string $vid
+   *   Taxonomy vocabulary ID.
+   * @param int $count
+   *   Number of terms that needs to be generated.
+   *
+   * @return array
+   *   Generated terms objects.
+   */
+  protected function generateDummyTerms($vid, $count) {
+    $terms = [];
+    for ($i = 0; $i <= $count; $i++) {
+      $terms[$i] = Term::create([
+        'vid'  => $vid,
+        'name' => $this->randomString(4),
+      ]);
+      $terms[$i]->save();
+    }
+    return $terms;
+  }
+
+  /**
+   * Generates a specified number of nodes of Article content type.
+   *
+   * @param int $count
+   *   Number of nodes that needs to be generated.
+   *
+   * @return array
+   *   Generated nodes objects.
+   */
+  protected function generateDummyArticles($count) {
+    $nodes = [];
+    for ($i = 0; $i <= $count; $i++) {
+      $nodes[$i] = Node::create([
+        'type'  => 'article',
+        'title' => $this->randomString(4),
+      ]);
+      $nodes[$i]->save();
+    }
+    return $nodes;
+  }
+
+  /**
+   * Perform clicking on the "Save" button.
+   */
+  protected function saveForm() {
+    $this->click('input[value="Save"]');
+  }
+
+  /**
+   * Make the screenshots.
+   */
+  protected function verboseCaptures() {
+    $directory = DRUPAL_ROOT . '/sites/simpletest/captures/';
+    if (!is_dir($directory)) {
+      mkdir($directory);
+    }
+    $path = $directory
+      . 'select2boxes_capture_'
+      . $this->capturesIndex++
+      . '.jpg';
+    $this->createScreenshot($path);
+  }
+
+}
