laravel-actions icon indicating copy to clipboard operation
laravel-actions copied to clipboard

Testing batched jobs

Open vpratfr opened this issue 1 year ago • 0 comments

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?

vpratfr avatar Feb 26 '24 17:02 vpratfr