Skip to content
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

[Bug]: closures as dataset argument values no longer supported #1269

Open
ragulka opened this issue Sep 20, 2024 · 0 comments
Open

[Bug]: closures as dataset argument values no longer supported #1269

ragulka opened this issue Sep 20, 2024 · 0 comments
Labels

Comments

@ragulka
Copy link

ragulka commented Sep 20, 2024

What Happened

The following used to work with Pest v2, but throws ErrorException: Undefined array key "user" in Pest v3

it('demonstrates the issue', function (User $user, mixed $expectedResult) {
    // assert here
})->with(function() {
    yield 'caseA' => [
        'user' => fn() => User::factory()->create(),
        'expectedResult' => true,
    ];
    
    yield 'caseB' => [
        'user' => fn() => User::factory()->create(),
        'expectedResult' => false,
    ];
});

In Pest v3, all arguments must be wrapped in a closure, instead:

it('demonstrates the issue', function (User $user, mixed $expectedResult) {
    // assert here
})->with(function() {
    yield 'caseA' => fn() => [
        'user' => User::factory()->create(),
        'expectedResult' => true,
    ];
    
    yield 'caseB' => fn() => [
        'user' => User::factory()->create(),
        'expectedResult' => false,
    ];
});

The main issue is that this seems to be an undocumented breaking change.

How to Reproduce

See above

Sample Repository

No response

Pest Version

3.10

PHP Version

8.3

Operation System

macOS

Notes

No response

@ragulka ragulka added the bug label Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant