playwright-community / jest-playwright

Running tests using Jest & Playwright
MIT License
532 stars 75 forks source link

how to integrate with `@next/env` #774

Closed chenrui333 closed 2 years ago

chenrui333 commented 3 years ago

I have little bit trouble of integrating with the jest-playwright with nextjs.

I was trying to to apply the similar change as I did with jest unit tests (nextjs doc ref) as below:

import { loadEnvConfig } from '@next/env';

module.exports = async () => {
  loadEnvConfig(process.env.PWD);
};

But it did not quite work out for jest-playwright integration, so I wonder what would be possible solution to integrate with nextjs config, thanks!

mxschmitt commented 2 years ago

jest-playwright is in maintenance mode, we recommend switching to the official test-runner: https://playwright.dev/docs/intro

For @playwright/test you can load it inside your playwright.config.ts which makes the environment variables available inside every test.