Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling seeders in beforeAll #1094

Open
mokhosh opened this issue Feb 15, 2024 · 0 comments
Open

Calling seeders in beforeAll #1094

mokhosh opened this issue Feb 15, 2024 · 0 comments
Labels

Comments

@mokhosh
Copy link

mokhosh commented Feb 15, 2024

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:

beforeAll(fn () => seed());

This is also mentioned in #237 and #246 and #33 (comment)
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:

  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▕ });

Pest Version

2.33.66

PHP Version

8.3.2

Operation System

macOS

@mokhosh mokhosh added the bug label Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant