Skip to content

Commit

Permalink
Freeze time to fix flakey tests
Browse files Browse the repository at this point in the history
  • Loading branch information
timacdonald committed Mar 15, 2024
1 parent b5f89b7 commit d1a83ea
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/Feature/Recorders/QueuesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
use Laravel\Pulse\Facades\Pulse;
use Laravel\Pulse\Recorders\Queues;

use function Pest\Laravel\freezeTime;

function queueAggregates()
{
return Pulse::ignore(fn () => DB::table('pulse_aggregates')->whereIn('type', [
Expand All @@ -32,6 +34,10 @@ function queueAggregates()
])->get());
}

beforeEach(function () {
freezeTime();
});

it('ingests bus dispatched jobs', function () {
Config::set('queue.default', 'database');

Expand Down Expand Up @@ -376,6 +382,7 @@ function queueAggregates()
Pulse::ignore(fn () => expect(Queue::size())->toBe(1));
$aggregates = queueAggregates();
expect($aggregates)->toHaveCount(12);
// Fail...
expect($aggregates)->toContainAggregateForAllPeriods(
type: 'queued',
aggregate: 'count',
Expand Down

0 comments on commit d1a83ea

Please sign in to comment.