function ComponentRenderTest::testJsLibraryAttachesCorrectly
Tests that the correct libraries are put on the page using JS.
This also covers all the path translations necessary to produce the correct path to the assets.
File
- 
              core/tests/ Drupal/ FunctionalJavascriptTests/ Components/ ComponentRenderTest.php, line 50 
Class
- ComponentRenderTest
- Tests the correct rendering of components.
Namespace
Drupal\FunctionalJavascriptTests\ComponentsCode
public function testJsLibraryAttachesCorrectly() : void {
  $build = [
    '#type' => 'inline_template',
    '#template' => "{{ include('sdc_test:my-button', {\n        text: 'Click'\n      }, with_context = false) }}",
  ];
  \Drupal::state()->set('sdc_test_component', $build);
  $this->drupalGet('sdc-test-component');
  $page = $this->getSession()
    ->getPage();
  $page->find('css', '[data-component-id="sdc_test:my-button"]')
    ->click();
  $this->assertSame('Click power (1)', $page->find('css', '[data-component-id="sdc_test:my-button"]')
    ->getText());
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
