mkdir permission denied error when running Browser based test
Maybe the Permission problems section of Running PHPUnit tests can help you:

Note: functional tests have to be invoked with a user in the same group as the web server user. You can either configure Apache (or nginx) to run as your own system user or run tests as a privileged user instead.
To develop locally, a straightforward - but also less secure - approach is to run tests as your own system user. To achieve that, change the default Apache user to run as your system user. Typically, you'd need to modify /etc/apache2/envvars on Linux or /etc/apache2/httpd.conf on Mac.
Example for Linux:

export APACHE_RUN_USER=&lt;your-user&gt;
export APACHE_RUN_GROUP=&lt;your-group&gt;


If the default user is e.g. www-data, the above functional tests will have to be invoked with sudo instead:

export SIMPLETEST_DB='mysql://root@localhost/dev_d8'
export SIMPLETEST_BASE_URL='http://d8.dev'
sudo -u www-data -E ./vendor/bin/phpunit -c core --testsuite functional
sudo -u www-data -E ./vendor/bin/phpunit -c core --testsuite functional-javascript