Skip to content

Conversation

9aoy
Copy link
Contributor

@9aoy 9aoy commented Sep 30, 2025

Summary

Support custom environment variables via env option, which can be available on process.env during testing.

import { defineConfig } from '@rstest/core';

export default defineConfig({
  env: {
    PRINT_LOGGER: 'true',
  },
});

After setting the above configuration, you can access the PRINT_LOGGER variable in your tests:

import { describe, it } from '@rstest/core';

if (process.env.PRINT_LOGGER === 'true') {
  console.log('PRINT_LOGGER is enabled');
}

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@Copilot Copilot AI review requested due to automatic review settings September 30, 2025 10:23
Copy link

netlify bot commented Sep 30, 2025

Deploy Preview for rstest-dev ready!

Name Link
🔨 Latest commit 25fdf7c
🔍 Latest deploy log https://app.netlify.com/projects/rstest-dev/deploys/68dbb04129067a0008eff5f6
😎 Deploy Preview https://deploy-preview-611--rstest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for custom environment variables through a new env configuration option, allowing users to define custom environment variables that will be available via process.env during test execution.

  • Adds env configuration option of type Partial<NodeJS.ProcessEnv>
  • Implements environment variable setup in the worker runtime
  • Adds comprehensive documentation for both English and Chinese locales

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/core/src/types/config.ts Defines the new env configuration option type
packages/core/src/types/worker.ts Adds env to the runtime configuration type
packages/core/src/config.ts Sets default empty object for env configuration
packages/core/src/pool/index.ts Passes env configuration to runtime config
packages/core/src/runtime/worker/index.ts Implements environment variable setup logic
website/theme/components/ConfigOverview.tsx Updates UI to include env in runtime configuration group
website/docs/en/config/test/env.mdx Adds English documentation for the new option
website/docs/zh/config/test/env.mdx Adds Chinese documentation for the new option
website/docs/en/config/test/_meta.json Updates English navigation metadata
website/docs/zh/config/test/_meta.json Updates Chinese navigation metadata
e2e/env/index.test.ts Adds end-to-end test for environment variable functionality
e2e/env/fixtures/rstest.config.ts Test configuration demonstrating env usage
e2e/env/fixtures/index.test.ts Test case verifying environment variable access

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant