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
It feels a bit awkward to me to write $this-> inside of a beforeEach() since I'm not looking at a class Foo {}. So, this idea borrows from Vue 3's setup() construct where anything returned from setup() in Vue is automatically available within the <template>.
What if anything returned from a beforeEach() or a beforeAll() was automatically merged and passed in to each test. Something like this,
beforeEach(fn () => [
'user' => $user = User::factory()->create(),
'post' => Post::factory()->create(['author_id' => $user->id]),
]);
it('expects a post to have one and only one author', function (User$user, Post$post]) {
expect($post)->author->id->toBe($user->id);
}
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
-
It feels a bit awkward to me to write
$this->
inside of abeforeEach()
since I'm not looking at aclass Foo {}
. So, this idea borrows from Vue 3'ssetup()
construct where anything returned fromsetup()
in Vue is automatically available within the<template>
.What if anything returned from a
beforeEach()
or abeforeAll()
was automatically merged and passed in to each test. Something like this,Beta Was this translation helpful? Give feedback.
All reactions