Closed roni-estein closed 4 years ago
This looks like the expected behaviour to me. In your unexpected case, you're running User::first()
right away instead of queuing it up in a closure to go in your testcase once the application is booted and beforeEach
has run. If you update your dd
method to accept a closure and dump the results, that should solve your problem.
it('runs before each')
->dd(fn () => User::first())
->assertTrue(true);
When running code in the beforeEach function, the code the code is not run before higher order tests.
Here are some input output tests in a basic project
EXPECTED
UNEXPECTED, expecting same output as the last test
FINAL SANITY TESTS
Change to higher order beforeEach, no change in output
tests/Pest.php
tests/TestCase.php has these 2 additional functions
if you need any further information to debug this or there is a critical error in what I'm doing please let me know. Thanks.