Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(rum-core): fix some flaky tests #1561

Merged
merged 2 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/rum-core/test/common/xhr-patch.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ describe('xhrPatch', function () {
const req = new window.XMLHttpRequest()
const getEvents = registerEventListener(req)
req.open('GET', 'https://elastic.co/guide', true)
req.timeout = 1
req.addEventListener('loadend', () => {
expect(getEvents(done).map(e => e.event)).toEqual(['schedule', 'invoke'])
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,13 @@ describe('PerformanceMonitoring', function () {

it('should notify when a transaction has been filtered out', function () {
spyOn(configService, 'dispatchEvent')
var tr = new Transaction('transaction-no-duration', 'transaction-type')
tr.end()
// NOTE: tests in SauceLabs fail because the duration becomes 1. Setting the start & end
// times will ensure `duration` is 0.
var now = Date.now()
var tr = new Transaction('transaction-no-duration', 'transaction-type', {
startTime: now
})
tr.end(now)

var payload = performanceMonitoring.createTransactionPayload(tr)
expect(payload).toBeUndefined()
Expand Down
Loading