{"record":{"id":"90d134d66d1d07af","repo":"pestphp/pest","slug":"a-test-in-s-is-missing-its-description-please","errorCode":null,"errorMessage":"A test in [%s] is missing its description. Please give every test a description.","messagePattern":"A test in \\[(.+?)\\] is missing its description\\. Please give every test a description\\.","errorType":"exception","errorClass":"TestDescriptionMissing","httpStatus":null,"severity":"error","filePath":"src/Factories/TestCaseFactory.php","lineNumber":183,"sourceCode":"\n                $methodsCode\n            }\n            PHP;\n\n            eval($classCode);\n        } catch (ParseError $caught) {\n            throw new RuntimeException(sprintf(\n                \"Unable to create test case for test file at [%s]. \\n %s\",\n                $filename,\n                $classCode\n            ), 1, $caught);\n        }\n    }\n\n    public function addMethod(TestCaseMethodFactory $method): void\n    {\n        if ($method->description === null) {\n            throw new TestDescriptionMissing($method->filename);\n        }\n\n        if (array_key_exists($method->description, $this->methods)) {\n            throw new TestAlreadyExist($method->filename, $method->description);\n        }\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            }","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/pestphp/pest/blob/1af74a215c3a89bc7a44fc6f9322e369eaad2423/src/Factories/TestCaseFactory.php#L165-L201","documentation":"Every Pest test needs a human description. When TestCaseFactory::addMethod receives a method whose description is null (a test closure registered without a name), it throws TestDescriptionMissing, naming the file. The run aborts at load time so an anonymous test can never silently disappear from the suite.","triggerScenarios":"Calling test() with only a closure (no string first argument); constructing tests programmatically through the factories/API without setting a description; a helper that wraps test() and forgets to forward the description argument.","commonSituations":"Copy-pasting a test() call and deleting the string; writing tests through custom helper layers or plugins; migrating PHPUnit method-style tests where names came from method names, not strings.","solutions":["Give every test a description string: test('creates a user', function () { ... });","If you build tests dynamically, ensure the description variable is always a non-empty string before calling test()/it().","Adopt it()/test() with meaningful names — the description is also the failure output, so a missing one hides failures."],"exampleFix":"// before\ntest(function () {\n    expect(1)->toBe(1);\n});\n// after\ntest('one is one', function () {\n    expect(1)->toBe(1);\n});","handlingStrategy":"validation","validationCode":"// in shared helpers that create tests programmatically:\nfunction testName(string $description, Closure $closure): void\n{\n    if (trim($description) === '') {\n        throw new InvalidArgumentException('Test description is required');\n    }\n\n    test($description, $closure);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass a description string as the first argument to test()/it().","Wrap programmatic test creation in helpers that validate the description.","Code-review rule: a bare test(function...) with no title never merges."],"tags":["pest","test-description","validation","load-time"],"backgroundTag":"missing-test-name","analyzedSha":"1af74a215c3a89bc7a44fc6f9322e369eaad2423","analyzedAt":"2026-08-21T02:16:38.132Z","schemaVersion":2},"datasetVersion":"2026-08-21T03:17:12.404Z"}