lorisleiva / laravel-actions

⚡️ Laravel components that take care of one specific task
https://laravelactions.com
MIT License
2.41k stars 117 forks source link

Testing batched jobs #270

Open vpratfr opened 5 months ago

vpratfr commented 5 months ago

Hi,

I got an action which dispatches jobs (which are actions too, hurray). Looks like that:

$documents->each(fn($doc) => GenerateDocumentFiles::dispatch($doc));

and is tested nicely with that

ProcessMissionDeliverable::assertPushedOn('default', 2);

Moving to batches

I wanted to move to batches. So I did that :

$jobs = $documents->map(fn($doc) => GenerateDocumentFiles::makeJob($doc));

Bus::batch($jobs->toArray())->dispatch();

However now my test is failing and saying that no jobs have been dispatched.

Any advices on how to test that?