Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(e2e): allow overwriting env variables in setup #903

Merged
merged 1 commit into from
Jul 26, 2024

Conversation

markbrockhoff
Copy link
Contributor

Hi,

I noticed that the nuxt server launched by the playwright fixture always uses the current environment variables without the option to overwrite them. So I exposed the already existing option to overwrite them from the startServer command into the playwright config. This way it's possible to define env variables to use during testing either globally or even overwrite them per test.

Example:

export default defineConfig<ConfigOptions>({
  use: {
    nuxt: {
      rootDir: fileURLToPath(new URL(".", import.meta.url)),
      env: {
        // Overwrite backend url during tests. This way the .env can still contain the real one used during development.
        NUXT_BACKEND_URL: "http://mocked-backend.example/api",
      },
    },
  },
});

@markbrockhoff markbrockhoff requested a review from danielroe as a code owner July 22, 2024 13:35
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. enhancement New feature or request labels Jul 22, 2024
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jul 26, 2024
@danielroe danielroe changed the title feat(playwright): expose config "env" to overwrite env variables during test feat(e2e): allow overwriting env variables in setup Jul 26, 2024
@danielroe danielroe merged commit f310a05 into nuxt:main Jul 26, 2024
4 checks passed
@github-actions github-actions bot mentioned this pull request Jul 26, 2024
@markbrockhoff markbrockhoff deleted the overwrite-env branch July 29, 2024 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants