Skip to content

Conversation

@9aoy
Copy link
Contributor

@9aoy 9aoy commented Oct 21, 2025

Summary

By default, Rstest saves snapshot files in the same directory as the test files, under a __snapshots__ folder.

You can use resolveSnapshotPath to customize this behavior and specify a different location for your snapshot files.

For example, store snapshots next to test files:

import { defineConfig } from '@rstest/core'; export default defineConfig({ resolveSnapshotPath: (testPath, snapshotExtension) => testPath + snapshotExtension, });

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).
Copilot AI review requested due to automatic review settings October 21, 2025 06:26
@netlify
Copy link

netlify bot commented Oct 21, 2025

Deploy Preview for rstest-dev ready!

Name Link
🔨 Latest commit 253adc2
🔍 Latest deploy log https://app.netlify.com/projects/rstest-dev/deploys/68f7280eee17cc00084e9351
😎 Deploy Preview https://deploy-preview-632--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 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 the resolveSnapshotPath configuration option, allowing users to customize where snapshot files are stored. By default, Rstest saves snapshots in a __snapshots__ folder alongside test files, but this option enables alternative storage strategies like placing snapshots directly next to test files.

  • Adds resolveSnapshotPath configuration option to customize snapshot file locations
  • Updates documentation in both English and Chinese to explain the new option
  • Implements the feature with a custom snapshot environment class and RPC integration

Reviewed Changes

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

Show a summary per file
File Description
packages/core/src/types/config.ts Adds resolveSnapshotPath type definition to config interface and marks it as optional
packages/core/src/types/worker.ts Extends RuntimeRPC interface with resolveSnapshotPath method
packages/core/src/pool/index.ts Implements default snapshot path resolution logic with fallback to __snapshots__ folder
packages/core/src/runtime/worker/snapshot.ts Extends snapshot environment to support custom path resolution
packages/core/src/runtime/worker/index.ts Integrates custom snapshot path resolver into worker initialization
website/theme/components/ConfigOverview.tsx Adds resolveSnapshotPath to configuration overview list
website/docs/en/config/test/resolveSnapshotPath.mdx Adds English documentation for the new option
website/docs/zh/config/test/resolveSnapshotPath.mdx Adds Chinese documentation for the new option
website/docs/en/config/test/_meta.json Registers new documentation page in English navigation
website/docs/zh/config/test/_meta.json Registers new documentation page in Chinese navigation
e2e/snapshot/fixtures/rstest.snapshotPath.config.ts Adds test configuration demonstrating custom snapshot path usage
e2e/snapshot/fixtures/index.test.ts.snap Adds expected snapshot file for e2e test
e2e/snapshot/file.test.ts Adds e2e test verifying resolveSnapshotPath functionality

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

const resolver =
context.normalizedConfig.resolveSnapshotPath ||
// test/index.ts -> test/__snapshots__/index.ts.snap
(() =>
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

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

[nitpick] This arrow function is defined inline but never reused. Consider extracting it to a named function getDefaultSnapshotPath for better readability and testability.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@9aoy 9aoy requested a review from Timeless0911 October 21, 2025 06:43
@9aoy 9aoy merged commit 447a706 into main Oct 21, 2025
28 of 29 checks passed
@9aoy 9aoy deleted the resolveSnapshotPath branch October 21, 2025 06:58
@9aoy 9aoy mentioned this pull request Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants