You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
uses()
->beforeEach(function () {
$this->user = User::factory()->create();
$this->actingAs($this->user);
})
->group('authed');
test('authenticated user is logged in', function () {
expect(auth()->check())->toBeTrue();
})->group('authed');
However it seems like the group on the uses isn't filtering that beforeEach to certain groups, but rather saying that anything is that group. It would be great to have an option for like forGroup for mass-applying specific beforeEach (and other) calls to apply logic across the board to a variety of tests without repeating it in each file or restricting it to certain folders.
The folder approach doesn't work for me as I'm mirroring the app structure, so not all tests in Http\Controllers are authenticated.
Have I missed anything or is this currently not possible?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I thought this would work:
However it seems like the
group
on theuses
isn't filtering that beforeEach to certain groups, but rather saying that anything is that group. It would be great to have an option for likeforGroup
for mass-applying specificbeforeEach
(and other) calls to apply logic across the board to a variety of tests without repeating it in each file or restricting it to certain folders.The folder approach doesn't work for me as I'm mirroring the app structure, so not all tests in
Http\Controllers
are authenticated.Have I missed anything or is this currently not possible?
Beta Was this translation helpful? Give feedback.
All reactions