I'm writing front end tests for a custom webform. These tests work fine when testing on the webform page of the form.
$this->drupalGet('/webform/custom_form');
$this->assertResponse(200);
However, testing the form using a custom theme and the page that the form is displayed on, does not work and the assertion fails returning a 404 response.
<?php
namespace Drupal\Tests\test_module\Kernel;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\webform\Functional\Element\WebformElementBrowserTestBase;
class WebformValidationTest extends WebformElementBrowserTestBase {
public static $modules = [
'webform',
'test_module',
];
public static $testWebforms = ['custom_form'];
protected $defaultTheme = 'custom_theme';
/**
* Test custom_form page from site with custom_theme theme install.
*
* @throws \Exception
*/
public function testThemeFormPage() {
$this->drupalGet('/page-that-displays-form');
$this->assertResponse(200);
}
}
I have also tried creating a submodule that imports the full config and installs all dependent modules from the site. This also did not work.
Is writing front end tests for specific nodes something that is possible with Drupal Browser Tests? If not, how does one write tests for webforms (validation, fields, display, etc)?
Thanks.