test(shard): cover module test classes outside the tests directory (#1689)

* test(shard): cover module test classes outside the tests directory

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* chore: refresh the snapshot counts

---------

Co-authored-by: Paul Sochiera <paul.sochiera@gmail.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Punyapal Shah <mrpunyapal@gmail.com>
This commit is contained in:
Paul Sochiera
2026-10-25 19:31:09 +01:00
committed by GitHub
parent d534cb2c40
commit f730a186ce
3 changed files with 25 additions and 2 deletions
+2 -1
View File
@@ -1860,6 +1860,7 @@
✓ parseListTestsOutput → it deduplicates repeated class names from multiple test methods
✓ parseListTestsOutput → it returns an empty list for output with no matching lines
✓ parseListTestsOutput → it parses non-Tests namespaced classes
✓ parseListTestsOutput → it parses module test classes living outside the tests directory
✓ parseListTestsOutput → it parses unnamespaced top-level classes
✓ parseListTestsOutput → it strips the P\ Pest prefix but keeps the rest of the FQCN
✓ parseListTestsOutput → it ignores junk lines that lack the " - …::" framing
@@ -2273,4 +2274,4 @@
✓ pass with dataset with ('my-datas-set-value')
✓ within describe → pass with dataset with ('my-datas-set-value')
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 35 skipped, 1612 passed (3518 assertions)
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 35 skipped, 1613 passed (3519 assertions)
+22
View File
@@ -376,6 +376,28 @@ OUT;
]);
});
it('parses module test classes living outside the tests directory', function (): void {
$output = new BufferedOutput;
$shard = new Shard($output);
$reflection = new ReflectionClass($shard);
$method = $reflection->getMethod('parseListTestsOutput');
$listOutput = <<<'OUT'
INFO Available tests:
- P\Tests\Unit\Foo::__pest_evaluable_it_works
- P\Modules\Example\tests\ShardModuleExample::__pest_evaluable_module_test_is_listed
- P\Modules\Billing\Tests\Feature\InvoiceTest::__pest_evaluable_it_creates_invoices
OUT;
expect($method->invoke($shard, $listOutput))->toBe([
'Tests\\Unit\\Foo',
'Modules\\Example\\tests\\ShardModuleExample',
'Modules\\Billing\\Tests\\Feature\\InvoiceTest',
]);
});
it('parses unnamespaced top-level classes', function (): void {
$output = new BufferedOutput;
$shard = new Shard($output);
+1 -1
View File
@@ -20,7 +20,7 @@ test('parallel', function () use ($run): void {
$output = $run('--exclude-group=integration');
$output = implode("\n", array_slice(explode("\n", (string) $output), -10));
$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1593 passed (3460 assertions)';
$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1594 passed (3461 assertions)';
expect($output)
->toContain("Tests: {$expected}")