Skip to content

feat: add defineProject helper#670

Merged
9aoy merged 1 commit intomainfrom
defineProject
Nov 5, 2025
Merged

feat: add defineProject helper#670
9aoy merged 1 commit intomainfrom
defineProject

Conversation

@9aoy
Copy link
Copy Markdown
Collaborator

@9aoy 9aoy commented Nov 5, 2025

Summary

defineProject helps you to autocomplete configuration types. It accepts a Rstest project config object, or a function that returns a config.

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

export default defineProject({
  setupFiles: ['./rstest.setup.ts'],
});

Related Links

close: #668

Checklist

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

Copilot AI review requested due to automatic review settings November 5, 2025 06:46
@netlify
Copy link
Copy Markdown

netlify bot commented Nov 5, 2025

Deploy Preview for rstest-dev ready!

Name Link
🔨 Latest commit 33b9f34
🔍 Latest deploy log https://app.netlify.com/projects/rstest-dev/deploys/690af2e278daca000756240c
😎 Deploy Preview https://deploy-preview-670--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 a defineProject helper function to enable TypeScript autocomplete for project-specific configurations, similar to the existing defineConfig function. It also extends the ProjectConfig type to exclude additional root-level configuration options that shouldn't be available at the project level.

  • Added defineProject function with overloads for sync/async/union types to support project-level configuration
  • Extended ProjectConfig to exclude resolveSnapshotPath, onConsoleLog, and hideSkippedTests from project-level configs
  • Fixed documentation comment typo referring to "Rsbuild" instead of "Rstest"

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/core/src/types/config.ts Expanded ProjectConfig to exclude three additional root-level options (resolveSnapshotPath, onConsoleLog, hideSkippedTests)
packages/core/src/index.ts Added defineProject helper function with type overloads and corrected documentation comment

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +45 to +49
type ProjectConfigAsyncFn = () => Promise<ProjectConfig>;

type ProjectConfigSyncFn = () => ProjectConfig;

type RstestProjectConfigExport =
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

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

The new type aliases ProjectConfigAsyncFn, ProjectConfigSyncFn, and RstestProjectConfigExport are not exported, while the equivalent RstestConfigAsyncFn, RstestConfigSyncFn, and RstestConfigExport types are exported. Consider exporting these types for consistency and to allow consumers to reference them in their own type definitions.

Suggested change
type ProjectConfigAsyncFn = () => Promise<ProjectConfig>;
type ProjectConfigSyncFn = () => ProjectConfig;
type RstestProjectConfigExport =
export type ProjectConfigAsyncFn = () => Promise<ProjectConfig>;
export type ProjectConfigSyncFn = () => ProjectConfig;
export type RstestProjectConfigExport =

Copilot uses AI. Check for mistakes.
@9aoy 9aoy merged commit 67e28f8 into main Nov 5, 2025
23 checks passed
@9aoy 9aoy deleted the defineProject branch November 5, 2025 09:44
@9aoy 9aoy mentioned this pull request Nov 5, 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.

[Feature]: Add defineProject() helper

2 participants