Skip to content

[8.x] possible fix for $__latestDescription error #332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: v8.x
Choose a base branch
from

Conversation

pintend
Copy link

@pintend pintend commented Jul 17, 2025

possible fix for $__latestDescription must not be accessed before initialization

pestphp/pest#978

we can't rely on the latest test description as a test might not have run yet, or in the case of multiple failed tests all the tests might show the latest working test name (failed or passed - working as in no uncaught exceptions)

dataset('sample data', function () {
    throw new \Exception('test');

    return [1, 2, 3];
});

test('first', function () {
    expect(true)->toBeTrue();
});

test('second', function () {
    expect(true)->toBeTrue();
});


test('sample', function () {
    expect(true)->toBeTrue();
})->with('sample data');

test('sample 2', function () {
    expect(true)->toBeTrue();
})->with('sample data');

BEFORE:

   FAIL  Tests\Unit\DatasetTest
  ⨯ second
  ⨯ second
  ✓ first
  ✓ second

   PASS  Tests\Unit\ExampleTest
  ✓ that true is true

   PASS  Tests\Feature\ExampleTest
  ✓ the application returns a successful response                                                                                                  0.05s  
  ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────  
   FAILED  Tests\Unit\DatasetTest > second                                                                                                                
  The data provider specified for P\Tests\Unit\DatasetTest::__pest_evaluable_sample is invalid
test

  ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────  
   FAILED  Tests\Unit\DatasetTest > second                                                                                                                
  The data provider specified for P\Tests\Unit\DatasetTest::__pest_evaluable_sample_2 is invalid
test

AFTER:

  FAIL  Tests\Unit\DatasetTest
 ⨯ sample
 ⨯ sample 2
 ✓ first                                                                                                                                          0.01s  
 ✓ second

  PASS  Tests\Unit\ExampleTest
 ✓ that true is true                                                                                                                              0.01s  

  PASS  Tests\Feature\ExampleTest
 ✓ the application returns a successful response                                                                                                  0.07s  
 ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────  
  FAILED  Tests\Unit\DatasetTest > sample                                                                                                                
 The data provider specified for P\Tests\Unit\DatasetTest::__pest_evaluable_sample is invalid
test

 ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────  
  FAILED  Tests\Unit\DatasetTest > sample 2                                                                                                              
 The data provider specified for P\Tests\Unit\DatasetTest::__pest_evaluable_sample_2 is invalid
test

(I only tested this on v8)

@pintend
Copy link
Author

pintend commented Jul 17, 2025

Nevermind this breaks custom names, we might need to update pest repo

@pintend pintend closed this Jul 17, 2025
@pintend
Copy link
Author

pintend commented Jul 17, 2025

So there are two issues

  1. LatestTest might be blank
  2. LatestTest might be the wrong test

the latest description probably needs to just be set earlier before data providers are called

@pintend pintend reopened this Jul 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant