testing – FunctionalJavascript tests fail with InvalidCookieDomain error

If I run a FunctionalJavascript test, it fails with:

WebDriverExceptionInvalidCookieDomain: invalid cookie domain

Does anyone know would could be causing this or how I could get it to output what the invalid domain is and what is invalid about it?

I am running the test like this:

vendor/bin/phpunit -v -c core/phpunit.xml.dist core/modules/system/tests/src/FunctionalJavascript/FrameworkTest.php

(phpunit.xml.dist has to be suitably configured.)

I see the same result using run-tests.sh.