Interpolated dataset names
What:
- [ ] Bug Fix
- [X] New Feature
Description:
This PR is to add the functionality I described in a recent discussion thread.
This PR is solving the problem that though we can name our datasets, we are not able to take a step further and use those dataset names fluently inside of a test name.
To do this you add :dataset into your test name, and the dataset name will be interpolated into the test name string. Similar to Laravel's :attribute inside validation strings
I am very open to any changes!
I targeted 3.x because this would be a breaking change, even if :dataset is unlikely.
Contrived Example
Before
Test
it('can sort by all fields', function (/* ... */) {
/* ... */
})->with([
'name' => [ /* ... */ ],
'email' => [ /* ... */ ],
'created_at' => [ /* ... */]
]);
Pest output
PASS Tests\Feature\TableSortTest
✓ it can sort by all fields with dataset "name"
✓ it can sort by all fields with dataset "email"
✓ it can sort by all fields with dataset "created_at"
After
Test
it('can sort by :dataset field', function (/* ... */) {
/* ... */
})->with([
'name' => [ /* ... */ ],
'email' => [ /* ... */ ],
'created_at' => [ /* ... */]
]);
Pest output
PASS Tests\Feature\TableSortTest
✓ it can sort by "name" field
✓ it can sort by "email" field
✓ it can sort by "created_at" field
Questions
I'm not a huge fan of where this functionality is, but I'm not sure where else it could be refactored to. Especially needing to remove the 'dataset ' that is already on the name. However any other approach would require significantly more refactoring I believe.
- Is this functionality worth pursuing?
- Should I move this somewhere else?
- Should I do any other manipulation to the dataset name? Should it have the
"..."s on named sets and(...)on unnamed sets? - Should I use some other string than
:dataset?