{"record":{"id":"033aeea23995fefb","repo":"pestphp/pest","slug":"the-fixture-file-file-does-not-exist","errorCode":null,"errorMessage":"The fixture file [$file] does not exist.","messagePattern":"The fixture file \\[\\$file\\] does not exist\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Functions.php","lineNumber":241,"sourceCode":"            $configurationRepository->globalConfiguration('default')->class(...$targets); // @phpstan-ignore-line\n        }\n    }\n}\n\nif (! function_exists('fixture')) {\n    function fixture(string $file): string\n    {\n        $file = implode(DIRECTORY_SEPARATOR, [\n            TestSuite::getInstance()->rootPath,\n            TestSuite::getInstance()->testPath,\n            'Fixtures',\n            str_replace(['/', '\\\\'], DIRECTORY_SEPARATOR, $file),\n        ]);\n\n        $fileRealPath = realpath($file);\n\n        if ($fileRealPath === false) {\n            throw new InvalidArgumentException(\n                'The fixture file ['.$file.'] does not exist.',\n            );\n        }\n\n        return $fileRealPath;\n    }\n}\n\nif (! function_exists('visit')) {\n    /**\n     * @template TUrl of array<int, string>|string\n     *\n     * @param  TUrl  $url\n     * @param  array<string, mixed>  $options\n     * @return (TUrl is array<int, string> ? ArrayablePendingAwaitablePage : PendingAwaitablePage)\n     */\n    function visit(array|string $url, array $options = []): ArrayablePendingAwaitablePage|PendingAwaitablePage\n    {","sourceCodeStart":223,"sourceCodeEnd":259,"githubUrl":"https://github.com/pestphp/pest/blob/1af74a215c3a89bc7a44fc6f9322e369eaad2423/src/Functions.php#L223-L259","documentation":"The fixture() helper resolves a path as rootPath/testPath/Fixtures/<file> (slashes normalized per platform) and returns its realpath. If realpath() returns false — file or an ancestor directory missing — Pest throws InvalidArgumentException with the full resolved path. Note the base is always tests/Fixtures; paths outside it cannot be reached with fixture().","triggerScenarios":"fixture('invoices/sample.json') when tests/Fixtures/invoices/sample.json does not exist; wrong casing on case-sensitive filesystems (Fixture.json vs fixture.json); passing an absolute path or one that escapes Fixtures via ../..; forgetting that the .snapshot/.json file was never committed.","commonSituations":"Git checkouts missing binary/large fixtures excluded by .gitignore or LFS misconfiguration; renaming fixture folders without updating tests; parallel CI on Linux catching casing errors that macOS/Windows masked; teammates assuming fixture() reads arbitrary project files.","solutions":["Create the file under tests/Fixtures mirroring the path in the message (the message shows the exact resolved location).","Fix casing or path segments to match the filesystem exactly on Linux CI.","If the file lives elsewhere in the repo, reference it directly (e.g., dirname(__DIR__).'/stubs/x.json') instead of fixture(), which is rooted at tests/Fixtures.","Verify large/binary fixtures are committed (git lfs track) so fresh clones and CI get them."],"exampleFix":"// before\nit('parses config', function () {\n    $path = fixture('config.yml'); // tests/Fixtures/config.yml missing\n});\n// after: create tests/Fixtures/config.yml, or point at the real location\nit('parses config', function () {\n    $path = fixture('config.yml');\n});\n// mkdir -p tests/Fixtures && printf 'key: value\\n' > tests/Fixtures/config.yml","handlingStrategy":"validation","validationCode":"$relative = 'invoices/sample.json';\n$base = implode(DIRECTORY_SEPARATOR, [getcwd(), 'tests', 'Fixtures', ...explode('/', $relative)]);\nif (! file_exists($base)) {\n    throw new RuntimeException(\"Fixture missing: {$base}\");\n}\n$path = fixture($relative);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Commit every file referenced by fixture(); track large/binary fixtures with git lfs and verify fresh clones.","Keep fixture paths lowercase and consistent to avoid casing failures on Linux CI.","Run a meta-test that asserts all fixtures referenced in the suite exist."],"tags":["pest","fixture","file-not-found","filesystem","tests-directory"],"backgroundTag":"resource-file-not-found","analyzedSha":"1af74a215c3a89bc7a44fc6f9322e369eaad2423","analyzedAt":"2026-08-21T02:16:38.132Z","schemaVersion":2},"datasetVersion":"2026-08-21T03:17:12.404Z"}