Imagine if you have a large seeder that takes 5s to run, and you need to test 20 things after that seed.
If you seed at the beginning of each test you would be waiting a 100 seconds for those tests, but if you could run the seeder once, it will take about 5 seconds, which is a massive improvement.
Do beforeAll(fn () => seed()); in a pest test file and you will get this:
assert(array_key_exists(self::FILE, $trace))
at tests/Unit/SomeTest.php:7
3▕ use function Pest\Laravel\assertDatabaseHas;
4▕ use function Pest\Laravel\seed;
5▕
6▕ beforeAll(function () {
➜ 7▕ seed();
8▕ });
What Happened
Imagine if you have a large seeder that takes 5s to run, and you need to test 20 things after that seed.
If you seed at the beginning of each test you would be waiting a 100 seconds for those tests, but if you could run the seeder once, it will take about 5 seconds, which is a massive improvement.
Please provide a way for us to do this:
This is also mentioned in #237 and #246 and https://github.com/pestphp/pest/issues/33#issuecomment-658022624 but sadly they are closed and ignored, but this seems to be a big pain point and a deal breaker for a lot of people.
How to Reproduce
Do
beforeAll(fn () => seed());
in a pest test file and you will get this:Pest Version
2.33.66
PHP Version
8.3.2
Operation System
macOS