Thunder comes with an extensive set of tests and base classes, and you can benefit from that.
Thunder provides two base classes, ThunderTestBase.php for functional browser tests and
ThunderJavascriptTestBase.php for javascript tests. If you want to write tests for your project, you should use these
classes.
There are also some traits, that provides useful functionalities:
ThunderTestTrait.phpThunderJavascriptTrait.phpThunderArticleTestTrait.phpThunderCkEditorTestTrait.phpThunderMediaLibraryTestTrait.phpThunderFormFieldTestTrait.phpThunderMediaTestTrait.phpThunderMetaTagTrait.phpThunderParagraphsTestTrait.phpThunderGqlsTestTrait.php
With the help of the thunder_test_mock_request test module, it's easy to mock external requests and make your tests
more stable and reliable.
You just have to define the response for a request URL.
Drupal\thunder_test_mock_request\MockHttpClientMiddleware::addUrlResponse('https://oembed.com/providers.json', '/path/to/myresponse.json', ['Content-Type' => 'application/json']);Note: If thunder_test_mock_request is enabled, all external requests have to be mocked.
Running tests for a project isn't that easy. Since all your tests have the $profile variable set to 'thunder', the
test runs against a plain Thunder installation. So these test sites, wouldn't contain any configuration changes from
your project.
To prevent that, ThunderTestTrait.php can receive a database dump that is installed before the test
runs.
Before you create the database dump, you should install your site from configuration to have an empty site without any content.
drush si --existing-configAfter that create the database dump:
cd docroot
php ./core/scripts/db-tools.php dump-database-d8-mysql | gzip > thunder.sql.gzBefore you execute your test, you have to set the thunderDumpFile env variable.
export thunderDumpFile=/path/to/thunder.sql.gzNow you can execute your test, as described in the official Drupal documentation