Was the transaction really committed by the time you assert Queue::assertPushed()?
Jul 23, 2025
4
Level 2
Assert job dispatched after commit
Is there a way to assert that a job was dispatched after commit?
For example a job like this: ShipOrder::dispatch($order_details)->afterCommit();
When I assert like this: Queue::assertPushed(ShipOrder::class);
I get an error like this: The expected [ShipOrder] job was not pushed. Failed asserting that false is true.
I'm using Pest
Level 2
@Glukinho Yes it's like that. I've realized what the issue is after changing to DatabaseTransactions and got the same error. I had not imported the job class in test file. Thanks for the hint. It works now even with RefreshDatabase
Please or to participate in this conversation.