`doppler run` in WebStorm with Playwright

We use WebStorm and Node.js with Playwright for tests.

I want to use doppler run to inject environment variables for Playwright/Cypress tests.

This is easy enough using a package.json script to run the tests e.g.
"start": "doppler run -p x-tests -c ${ENV:-ci} -- pnpm playwright test"

My problem is that WebStorm doesn’t recognise this script as running Playwright, so I lose nice idea features like running particular tests.

To run Playwright scripts in WebStorm you need to use a run/debug configuration that looks like this

Ideally there would be a way to run a doppler run/export step/script/plugin in “Before Launch” that would populate the environment variables for the Playwright tests.

The only way I’ve got this working so far is to manually copy environment variables into the Playwright run configuration, but this is not viable long term for us.

Hi @seagullmouse!

Welcome to the Doppler Community!

Sometimes integrating Doppler with tools like this can be tricky for reasons like you discovered here. One approach that might work in your case is to use something like the gitops-secrets-nodejs package to generate encrypted secret bundles and then decrypt them in-app. It also has a function to populate the environment too. The bonus here could also be that you could have one script that runs once to generate the encrypted bundle and then your tests wouldn’t have to re-fetch secrets every time.

Would something like this work?

Regards,
-Joel

Thanks for this.
Ideally I don’t want to change the code itself to inject these variables. There are many other places where we need to run these playwright tests (pipelines, different IDEs, command lines etc), often the environment variables will come from different places. The beauty of doppler run is that it is external to the application/script that it runs.

I don’t mind using a script that fetches the secrets every time.

This does feel like a fiddly issue so I appreciate your help, IDEs don’t seem to provide ways to inject environment variables easily.