I have a React/TypeScript project running Playwright integration tests in an Azure DevOps pipeline. The pipeline gets environment variables from an Azure DevOps library.
I can run the tests locally against my deployed pre-prod environment successfully.
However, the tests fail in the pipeline. They fail because the pipeline cannot read the environment variables I am trying to pass in from the library.
Failing line of code:
await page.getByRole('textbox', { name: 'myVariable' }).fill(process.env.MyVariable as string);
Pipeline error on my environment variable:
How do I pass environment variables from the library to the pipeline such that Playwright can read them?
myFile.spec.ts
to myFile.spec.tsx
.REACT_APP_
.await page.getByRole('textbox', { name: 'myVariable' }).fill(process.env.REACT_APP_MY_VARIABLE as string);