Skip to content

Commit f833fcf

Browse files
Merge pull request #7290 from Shopify/fix-flaky-rate-limit-test
Fix flaky runWithRateLimit test by using fake timers
2 parents d40f170 + 13f2353 commit f833fcf

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

packages/cli-kit/src/private/node/conf-store.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ describe('runWithRateLimit', () => {
474474
test('throttles the task when the cache is populated recently', async () => {
475475
await inTemporaryDirectory(async (cwd) => {
476476
// Given
477+
vi.useFakeTimers()
477478
const config = new LocalStorage<any>({cwd})
478479
for (let i = 0; i < limit; i++) {
479480
// eslint-disable-next-line no-await-in-loop
@@ -511,6 +512,7 @@ describe('runWithRateLimit', () => {
511512
test("runs the task as usual when the cache is populated recently but the rate limit isn't used up", async () => {
512513
await inTemporaryDirectory(async (cwd) => {
513514
// Given
515+
vi.useFakeTimers()
514516
const config = new LocalStorage<any>({cwd})
515517
// Run the task once, but the rate limit is 2
516518
await runWithRateLimit(

0 commit comments

Comments
 (0)