I want to create a pnpm script that generates test data and runs my test on said data like so:
"e2e:test1": "bash ./generateTestData.sh && npx playwright test test1.spec.ts"
my data-gen script looks like this:
#!/bin/bash
# Generate a new patient
id=$(command to generate new patient here)
echo " Generated new patient"'
guid=$(...some other code to get the right values)
export GUID=$guid
As you can see here i want to set the reference to my generated patient in an env variable that i can then use in my playwright test to go to the right URL.
But if i run my commands like so:
pnpm e2e:test1 the env variable is not set in the playwright test. I also tried to use source like so:
"e2e:test1": "bash -c 'source generateTestData.sh && npx playwright test e2e/test1.spec.ts'"
that didnt work either.
How can I get the result of my data-generation into my playwright test?