But if you are doing integration tests, I'd highly recommend using docker instead.
That way, you can start a new container every time and you can easily provide the password you want to use by using ELASTIC_PASSWORD
.
For example: How to set elasticsearch user "elastic" password in Dockerfile - #2 by dadoonet