{"record":{"id":"3bc169bb818c8211","repo":"pestphp/pest","slug":"the-test-s-in-s-expects-d-argument-s","errorCode":null,"errorMessage":"The test [%s] in [%s] expects [%d] argument(s) ([%s]), but no dataset was provided. Please chain [with()] onto the test to supply one.","messagePattern":"The test \\[(.+?)\\] in \\[(.+?)\\] expects \\[(.+?)\\] argument\\(s\\) \\(\\[(.+?)\\]\\), but no dataset was provided\\. Please chain \\[with\\(\\)\\] onto the test to supply one\\.","errorType":"exception","errorClass":"DatasetMissing","httpStatus":null,"severity":"error","filePath":"src/Factories/TestCaseFactory.php","lineNumber":206,"sourceCode":"        }\n\n        if (\n            $method->closure instanceof \\Closure &&\n            new \\ReflectionFunction($method->closure)->isStatic()\n        ) {\n\n            throw new TestClosureMustNotBeStatic($method);\n        }\n\n        if (! $method->receivesArguments()) {\n            if (! $method->closure instanceof \\Closure) {\n                throw ShouldNotHappen::fromMessage('The test closure may not be empty.');\n            }\n\n            $arguments = Reflection::getFunctionArguments($method->closure);\n\n            if ($arguments !== []) {\n                throw new DatasetMissing($method->filename, $method->description, $arguments);\n            }\n        }\n\n        $this->methods[$method->description] = $method;\n    }\n\n    public function hasMethod(string $methodName): bool\n    {\n        foreach ($this->methods as $method) {\n            if ($method->description === null) {\n                throw ShouldNotHappen::fromMessage('The test description may not be empty.');\n            }\n\n            if ($methodName === Str::evaluable($method->description)) {\n                return true;\n            }\n        }\n","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/pestphp/pest/blob/1af74a215c3a89bc7a44fc6f9322e369eaad2423/src/Factories/TestCaseFactory.php#L188-L224","documentation":"If a test closure declares parameters and the test has no dataset, Pest cannot invoke it, so TestCaseFactory::addMethod throws DatasetMissing listing the file, description, and the expected argument names, with the hint to chain with(). Pest fails this at load time rather than letting every run crash with an ArgumentCountError.","triggerScenarios":"it('works', function (int $n) { ... }); with no ->with(...) chained; deleting a dataset while keeping the parameter; adding a parameter for a future dataset and committing before wiring ->with(); helper wrappers that strip the ->with() chain.","commonSituations":"Mid-refactor commits where the signature changed first; converting PHPUnit @dataProvider tests and forgetting the with() half; tutorials' copy-paste that omit the dataset; dataset provided conditionally (only in some suites) so the error appears only in certain environments.","solutions":["Chain a dataset: ->with([[1], [2]]) or ->with('datasets@case') for shared datasets in tests/Datasets.","If the parameter can be optional, give it a default (function (int $n = 1)) — closures with only optional args don't require a dataset.","If the parameter was a mistake, remove it from the closure signature.","For expensive/DB-bound data use a lazy dataset: ->with(fn () => [...])."],"exampleFix":"// before\nit('formats money', function (int $cents) {\n    expect(money($cents))->toBe('$1.00');\n});\n// after\nit('formats money', function (int $cents) {\n    expect(money($cents))->toBe('$1.00');\n})->with([[100]]);","handlingStrategy":"validation","validationCode":"// fail fast in helpers that register tests with parameters:\n$required = (new ReflectionFunction($closure))->getNumberOfRequiredParameters();\nif ($required > 0 && $dataset === null) {\n    throw new LogicException(\"Test [{$description}] has {$required} required parameter(s) but no dataset\");\n}\n$test = test($description, $closure);\nif ($dataset !== null) {\n    $test->with($dataset);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Chain ->with() in the same commit that adds a test parameter.","Give parameters defaults when the argument is genuinely optional.","Use shared datasets (datasets.php / 'datasets@name') so wiring is one short string."],"tags":["pest","dataset","missing-arguments","load-time","with"],"backgroundTag":"missing-test-dataset","analyzedSha":"1af74a215c3a89bc7a44fc6f9322e369eaad2423","analyzedAt":"2026-08-21T02:16:38.132Z","schemaVersion":2},"datasetVersion":"2026-08-21T03:17:12.404Z"}