Skip to content

feat: support inline project config#522

Merged
9aoy merged 3 commits intomainfrom
projectConfig
Aug 29, 2025
Merged

feat: support inline project config#522
9aoy merged 3 commits intomainfrom
projectConfig

Conversation

@9aoy
Copy link
Copy Markdown
Collaborator

@9aoy 9aoy commented Aug 29, 2025

Summary

Supports configuring projects inline in the projects field. This lets you define multiple test projects in a single root without creating separate config files for each test project.

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

export default defineConfig({
  projects: [
    // inline project configs
    {
      name: 'node',
      include: ['tests/node/**/*.{test,spec}.{js,cjs,mjs,ts,tsx}'],
    },
    {
      name: 'react',
      include: ['tests/react/**/*.{test,spec}.{js,cjs,mjs,ts,tsx}'],
      testEnvironment: 'jsdom',
    },
  ],
});

Related Links

Checklist

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

Copilot AI review requested due to automatic review settings August 29, 2025 08:16
@netlify
Copy link
Copy Markdown

netlify bot commented Aug 29, 2025

Deploy Preview for rstest-dev ready!

Name Link
🔨 Latest commit f827ce7
🔍 Latest deploy log https://app.netlify.com/projects/rstest-dev/deploys/68b161c96376550008724a3e
😎 Deploy Preview https://deploy-preview-522--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
Copy Markdown
Contributor

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 inline project configuration in the projects field, allowing users to define multiple test projects directly in the configuration without creating separate config files. This feature simplifies project setup for scenarios where multiple test environments need different configurations.

  • Updates type definitions to support both string and object configurations in the projects array
  • Modifies project resolution logic to handle inline configuration objects
  • Adds comprehensive documentation in both English and Chinese

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/core/src/types/config.ts Adds ProjectConfig type and updates TestProject to support inline configs
packages/core/src/types/core.ts Updates ProjectContext to use NormalizedProjectConfig type
packages/core/src/core/rstest.ts Updates type casting for project configuration normalization
packages/core/src/cli/init.ts Implements logic to handle inline project configurations during resolution
e2e/projects/inline.test.ts Adds end-to-end test for inline project configuration feature
e2e/projects/fixtures/rstest.inline.config.ts Test fixture demonstrating inline project configuration
website/docs/en/config/test/projects.mdx Updates English documentation with inline config examples
website/docs/zh/config/test/projects.mdx Updates Chinese documentation with inline config examples

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

Comment on lines +97 to +99
const config = withDefaultConfig(
project.config,
) as NormalizedProjectConfig;
Copy link

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

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

The type assertion as NormalizedProjectConfig is potentially unsafe. Consider using a type guard or ensuring withDefaultConfig returns the correct type to avoid runtime type mismatches.

Copilot uses AI. Check for mistakes.
).reduce(
(total, p) => {
const projectStr = p.replace('<rootDir>', root);
if (typeof p === 'object') {
Copy link

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

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

The type check typeof p === 'object' will return true for null values, which could cause runtime errors. Use typeof p === 'object' && p !== null or p && typeof p === 'object' to safely check for object types.

Suggested change
if (typeof p === 'object') {
if (typeof p === 'object' && p !== null) {

Copilot uses AI. Check for mistakes.
@9aoy 9aoy merged commit 9e50bbb into main Aug 29, 2025
17 checks passed
@9aoy 9aoy deleted the projectConfig branch August 29, 2025 09:35
@9aoy 9aoy mentioned this pull request Aug 29, 2025
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.

2 participants