[v8] Improve performance of audit log tests#1408
Merged
Conversation
Contributor
Greptile OverviewGreptile SummaryOptimized audit log retry tests by replacing real timers with Jest fake timers. Tests now execute instantly instead of waiting for actual retry delays (previously took 10+ seconds). Key Changes:
Impact:
Confidence Score: 5/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant Test as Test Suite
participant Jest as Jest Fake Timers
participant WorkOS as WorkOS Client
participant HTTP as HTTP Client
participant API as Mock API
Test->>Jest: jest.useFakeTimers()
Test->>WorkOS: createEvent('org_123', event)
WorkOS->>HTTP: post('/audit_logs/events')
HTTP->>API: Attempt 1
API-->>HTTP: 500 Error
HTTP->>HTTP: shouldRetryRequest() = true
HTTP->>Jest: setTimeout(sleep, ~500ms)
Note over HTTP,Jest: Timer scheduled but not executed
Test->>Jest: runAllTimersAsync()
Jest->>HTTP: Execute sleep callback
HTTP->>API: Attempt 2
API-->>HTTP: 500 Error
HTTP->>HTTP: shouldRetryRequest() = true
HTTP->>Jest: setTimeout(sleep, ~750ms)
Jest->>HTTP: Execute sleep callback
HTTP->>API: Attempt 3
API-->>HTTP: 201 Success
HTTP-->>WorkOS: Success response
WorkOS-->>Test: Promise resolves
Test->>Jest: jest.useRealTimers()
|
3eb5cff to
1b5124b
Compare
mattgd
approved these changes
Dec 2, 2025
nicknisi
added a commit
that referenced
this pull request
Dec 4, 2025
## Summary - Use Jest fake timers instead of real timers in audit log retry tests - Tests now run instantly instead of waiting for actual retry delays - Removes timeout extensions that were needed for slow tests
nicknisi
added a commit
that referenced
this pull request
Dec 4, 2025
## Summary - Use Jest fake timers instead of real timers in audit log retry tests - Tests now run instantly instead of waiting for actual retry delays - Removes timeout extensions that were needed for slow tests
nicknisi
added a commit
that referenced
this pull request
Dec 16, 2025
## Summary - Use Jest fake timers instead of real timers in audit log retry tests - Tests now run instantly instead of waiting for actual retry delays - Removes timeout extensions that were needed for slow tests
nicknisi
added a commit
that referenced
this pull request
Dec 22, 2025
## Summary - Use Jest fake timers instead of real timers in audit log retry tests - Tests now run instantly instead of waiting for actual retry delays - Removes timeout extensions that were needed for slow tests
nicknisi
added a commit
that referenced
this pull request
Jan 8, 2026
## Summary - Use Jest fake timers instead of real timers in audit log retry tests - Tests now run instantly instead of waiting for actual retry delays - Removes timeout extensions that were needed for slow tests
nicknisi
added a commit
that referenced
this pull request
Jan 9, 2026
## Summary - Use Jest fake timers instead of real timers in audit log retry tests - Tests now run instantly instead of waiting for actual retry delays - Removes timeout extensions that were needed for slow tests
nicknisi
added a commit
that referenced
this pull request
Jan 12, 2026
## Summary - Use Jest fake timers instead of real timers in audit log retry tests - Tests now run instantly instead of waiting for actual retry delays - Removes timeout extensions that were needed for slow tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary