pestphp / pestphp/pest

[4.x] Snapshots are not created because the file name is too long

Open
#1,422 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PHP
Stars
11.7k
Forks
538
Avg merge
4d 11h
Merged PRs (30d)
8

Description

What Happened

When running tests using the toMatchSnapshot method, the OS cannot create files because the name is too long (Windows, Ubuntu).

How to Reproduce
enum GroupEnum: int
{
    case LetterClothingSize = 1;
    case ClothesAndShoes    = 2;
    case BraSize            = 3;
    case OverallDimensions  = 4;
    case OtherSizes         = 5;

    public static function sorted(): array
    {
        return [
            self::LetterClothingSize,
            self::ClothesAndShoes,
            self::BraSize,
            self::OverallDimensions,
            self::OtherSizes,
        ];
    }
}
dataset('groups', [
    'empty' => [
        'input'  => null,
        'output' => GroupEnum::sorted(),
    ],

    'full' => [
        'input'  => GroupEnum::sorted(),
        'output' => GroupEnum::sorted(),
    ],

    'partial' => [
        'input' => [
            GroupEnum::OtherSizes,
            GroupEnum::BraSize,
        ],

        'output' => [
            GroupEnum::OtherSizes,
            GroupEnum::BraSize,
            GroupEnum::LetterClothingSize,
            GroupEnum::ClothesAndShoes,
            GroupEnum::OverallDimensions,
        ],
    ],

    'full random' => [
        'input' => [
            GroupEnum::OtherSizes,
            GroupEnum::BraSize,
            GroupEnum::ClothesAndShoes,
            GroupEnum::OverallDimensions,
            GroupEnum::LetterClothingSize,
        ],

        'output' => [
            GroupEnum::OtherSizes,
            GroupEnum::BraSize,
            GroupEnum::ClothesAndShoes,
            GroupEnum::OverallDimensions,
            GroupEnum::LetterClothingSize,
        ],
    ],
]);
test('sort', function (?array $input, array $output) {
    expect(['test'])->toMatchSnapshot();
})->with('groups');
Sample Repository

https://github.com/TheDragonCode/size-sorter/blob/main/tests/Unit/SizeSorter/GroupsTest.php

Pest Version

3.8.2

PHP Version

8.3.23

Operation System

Windows

Notes

[!NOTE]

I have provided a link to the test in the repository. See the very first test (sort) - this is it.

I tried running this code inside WSL (Ubuntu) and the tests showed identical behavior.

Snapshot paths:

D:\domains\dragon-code\size-sorter\tests/.pest\snapshots\Unit\SizeSorter\GroupsTest/sort_with_data_set__dataset__empty____null___DragonCode_SizeSorter_Enums_GroupEnum_Enum__LetterClothingSize__1___DragonCode_SizeSorter_Enums_GroupEnum_Enum__ClothesAndShoes__2___DragonCode_SizeSorter_Enums_GroupEnum_Enum__BraSize__3___DragonCode_SizeSorter_Enums_GroupEnum_Enum__OverallDimensions__4___DragonCode_SizeSorter_Enums_GroupEnum_Enum__OtherSizes__5___.snap
D:\domains\dragon-code\size-sorter\tests/.pest\snapshots\Unit\SizeSorter\GroupsTest/sort_with_data_set__dataset__full_____DragonCode_SizeSorter_Enums_GroupEnum_Enum__LetterClothingSize__1___DragonCode_SizeSorter_Enums_GroupEnum_Enum__ClothesAndShoes__2___DragonCode_SizeSorter_Enums_GroupEnum_Enum__BraSize__3___DragonCode_SizeSorter_Enums_GroupEnum_Enum__OverallDimensions__4___DragonCode_SizeSorter_Enums_GroupEnum_Enum__OtherSizes__5_____DragonCode_SizeSorter_Enums_GroupEnum_Enum__LetterClothingSize__1___DragonCode_SizeSorter_Enums_GroupEnum_Enum__ClothesAndShoes__2___DragonCode_SizeSorter_Enums_GroupEnum_Enum__BraSize__3___DragonCode_SizeSorter_Enums_GroupEnum_Enum__OverallDimensions__4___DragonCode_SizeSorter_Enums_GroupEnum_Enum__OtherSizes__5___.snap
D:\domains\dragon-code\size-sorter\tests/.pest\snapshots\Unit\SizeSorter\GroupsTest/sort_with_data_set__dataset__partial_____DragonCode_SizeSorter_Enums_GroupEnum_Enum__OtherSizes__5___DragonCode_SizeSorter_Enums_GroupEnum_Enum__BraSize__3_____DragonCode_SizeSorter_Enums_GroupEnum_Enum__OtherSizes__5___DragonCode_SizeSorter_Enums_GroupEnum_Enum__BraSize__3___DragonCode_SizeSorter_Enums_GroupEnum_Enum__LetterClothingSize__1___DragonCode_SizeSorter_Enums_GroupEnum_Enum__ClothesAndShoes__2___DragonCode_SizeSorter_Enums_GroupEnum_Enum__OverallDimensions__4___.snap
D:\domains\dragon-code\size-sorter\tests/.pest\snapshots\Unit\SizeSorter\GroupsTest/sort_with_data_set__dataset__full_random_____DragonCode_SizeSorter_Enums_GroupEnum_Enum__OtherSizes__5___DragonCode_SizeSorter_Enums_GroupEnum_Enum__BraSize__3___DragonCode_SizeSorter_Enums_GroupEnum_Enum__ClothesAndShoes__2___DragonCode_SizeSorter_Enums_GroupEnum_Enum__OverallDimensions__4___DragonCode_SizeSorter_Enums_GroupEnum_Enum__LetterClothingSize__1_____DragonCode_SizeSorter_Enums_GroupEnum_Enum__OtherSizes__5___DragonCode_SizeSorter_Enums_GroupEnum_Enum__BraSize__3___DragonCode_SizeSorter_Enums_GroupEnum_Enum__ClothesAndShoes__2___DragonCode_SizeSorter_Enums_GroupEnum_Enum__OverallDimensions__4___DragonCode_SizeSorter_Enums_GroupEnum_Enum__LetterClothingSize__1___.snap

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the first sort test in the referenced tests/Unit/SizeSorter/GroupsTest.php and reproduce it using toMatchSnapshot() with the groups dataset. Trace how the dataset and enum values become the snapshot path, then verify that the snapshots are created successfully on Windows and Ubuntu without exceeding filesystem filename limits.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.