Trying multiple ways here to set a default theme to use in FunctionalJavascript tests and it is not working (I am watching them execute in VNC viewer). Bartik always shows.

I also tried setting $defaultTheme to stark, it does not appear either. It is always Bartik. According to the class and docs, this is supported in Drupal 8.8.2.

How can I make my theme default and load? This is the class my FunctionalJavascript class tests extend:

abstract class WebDriverTestBase extends CoreWebDriverTestBase {

   * {@inheritdoc}
  protected $defaultTheme = 'MYTHEME';

  protected $profile = 'standard';

   * {@inheritdoc}
  protected $strictConfigSchema = FALSE;

   * {@inheritdoc}
  protected function setUp() {
    $this->container->get('theme_installer')->install(['MYTHEME'], TRUE);
    $this->container->get('config.factory')->getEditable('system.theme')->set('default', 'MYTHEME')->save();

Edit: command being run:

docker-compose exec --user=$DOCKER_COMPOSE_USER php phpunit --testsuite unit,kernel,functional,functional-javascript

My phpunit.xml.dist file has limited those suites to my modules/custom folder.

Edit 2:

I have now done the following:

drush si --sites-subdir=testing.docker.localhost
drush then MYTHEME
drush cedit system.theme (set MYTHEME default)
drush pm-uninstall page_cache
drush en mymodule_user_auth
drush cr
phpunit ....

I had to set the block too (one test looks for the presence of a block). Now the tests pass. But why is the setUp() method not doing the above even though its being told to do so? Regular Functional tests adhere to this, why not FunctionalJavascript ones?


I wound up installing a barebones install with drush si and exporting certain configuration to an install profile. After adding this to drush si in CI and local, all functional javascript browser tests work without complaints.

I double checked and the parent BrowserTestBase class does have defaultTheme and profile properties, so I don't know why those were not installed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.