(This is the sister issue of #2026255: Make CascadingStylesheetsTest 3500% faster.)
While working on #352951: Make JS & CSS Preprocessing Pluggable, I got very much fed up with the extreme slowness of JavaScriptTest.php
.
Difference
- Before: 610 seconds (10 min 10 sec)
- After: 19 seconds
- (That's 32.105 times faster, or only 3.11% of the original test running time.)
It used WebTestBase
for historical reasons, while it could easily use DrupalUnitTestBase
now.
Ideally, this would be a PHPUnit test, but that's not technically possible right now. This will at least make it a whole lot faster, while retaining the same test coverage.
Changes
I changed as little as possible:
DrupalWebTestBase
->DrupalUnitTestBase
- Removed the testing of the presence of
drupalSettings.currentPath
in the actual rendered HTML; it's already being tested higher up intestHeaderSetting()
anyway. - Instead of relying on a certain page callback in
common_test
module, which would indeed needWebTestBase
, I just moved the relevant parts ofcommon_test.module
into the test itself (2 lines of code).