For AI agents: the complete documentation index is available at https://rstest.rs/llms.txt, the full documentation bundle is available at https://rstest.rs/llms-full.txt, and this page is available as Markdown at https://rstest.rs/config/test/resolve-snapshot-path.md.
close
  • English
  • resolveSnapshotPath

    • Type: (testPath: string, snapExtension: string) => string
    • Default: undefined

    Customize where Rstest stores snapshot files.

    This is a global option set in the root config and cannot be overridden per project in projects.

    By default, Rstest saves snapshot files in a __snapshots__ directory next to each test file. Return a custom path from resolveSnapshotPath to change this location.

    For example, store snapshots beside test files instead of inside __snapshots__:

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