Skip to content

Commit af07767

Browse files
authored
Multiple test and test utils migrations to TS (#1447)
1 parent 459c418 commit af07767

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+521
-425
lines changed

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ The Session Replay feature utilizes our tracing infrastructure to:
190190
- **Unit Tests**: Component-focused tests in `test/replay/unit/`
191191
- **Integration Tests**: Test component interactions in `test/replay/integration/`
192192
- **End-to-End Tests**: Full flow verification in `test/replay/integration/e2e.test.js`
193-
- **Mock Implementation**: `test/replay/util/mockRecordFn.js` provides a deterministic mock of rrweb
193+
- **Mock Implementation**: `test/replay/util/mockRecordFn.ts` provides a deterministic mock of rrweb
194194
- **Fixtures**: Realistic rrweb events in `test/fixtures/replay/` for testing
195195
- **Test Tasks**: Dedicated test configurations for replay code specifically
196196

test/browser.core.test.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Tracing from '../src/tracing/tracing.js';
66

77
import { fakeServer } from './browser.rollbar.test-utils.ts';
88
import { loadHtml } from './util/fixtures.ts';
9-
import { setTimeout } from './util/timers.js';
9+
import { setTimeoutAsync } from './util/timers.ts';
1010

1111
describe('options', function () {
1212
beforeEach(function () {
@@ -132,7 +132,7 @@ describe('options.captureUncaught', function () {
132132
expect(element).to.exist;
133133
element.click();
134134

135-
await setTimeout(1, null);
135+
await setTimeoutAsync(1);
136136

137137
server.respond();
138138

@@ -168,7 +168,7 @@ describe('options.captureUncaught', function () {
168168

169169
element.click();
170170

171-
await setTimeout(1, null);
171+
await setTimeoutAsync(1);
172172

173173
server.respond();
174174
expect(server.requests.length).to.eql(0); // Disabled, no event
@@ -180,7 +180,7 @@ describe('options.captureUncaught', function () {
180180

181181
element.click();
182182

183-
await setTimeout(1, null);
183+
await setTimeoutAsync(1);
184184

185185
server.respond();
186186

@@ -197,7 +197,7 @@ describe('options.captureUncaught', function () {
197197

198198
element.click();
199199

200-
await setTimeout(1, null);
200+
await setTimeoutAsync(1);
201201

202202
server.respond();
203203
expect(server.requests.length).to.eql(0); // Disabled, no event
@@ -231,7 +231,7 @@ describe('options.captureUncaught', function () {
231231
Error.prepareStackTrace(e, []);
232232
}
233233

234-
await setTimeout(1, null);
234+
await setTimeoutAsync(1);
235235

236236
server.respond();
237237

@@ -268,7 +268,7 @@ describe('options.captureUncaught', function () {
268268
element.click(); // use for loop to ensure the stack traces have identical line/col info
269269
}
270270

271-
await setTimeout(1, null);
271+
await setTimeoutAsync(1);
272272

273273
server.respond();
274274

@@ -309,7 +309,7 @@ describe('options.captureUncaught', function () {
309309
element.click(); // use for loop to ensure the stack traces have identical line/col info
310310
}
311311

312-
await setTimeout(1, null);
312+
await setTimeoutAsync(1);
313313

314314
server.respond();
315315

@@ -344,7 +344,7 @@ describe('options.captureUncaught', function () {
344344
expect(element).to.exist;
345345
element.click();
346346

347-
await setTimeout(1, null);
347+
await setTimeoutAsync(1);
348348
server.respond();
349349

350350
const body = JSON.parse(server.requests[0].requestBody);
@@ -379,7 +379,7 @@ describe('options.captureUncaught', function () {
379379
expect(element).to.exist;
380380
element.click();
381381

382-
await setTimeout(1, null);
382+
await setTimeoutAsync(1);
383383

384384
server.respond();
385385

@@ -429,7 +429,7 @@ describe('options.captureUncaught', function () {
429429

430430
Promise.reject(new Error('test reject'));
431431

432-
await setTimeout(500, null);
432+
await setTimeoutAsync(500);
433433

434434
server.respond();
435435

@@ -462,7 +462,7 @@ describe('options.captureUncaught', function () {
462462

463463
Promise.reject(new Error('test reject'));
464464

465-
await setTimeout(500, null);
465+
await setTimeoutAsync(500);
466466

467467
server.respond();
468468

@@ -496,7 +496,7 @@ describe('options.captureUncaught', function () {
496496

497497
Promise.reject(new Error('test reject'));
498498

499-
await setTimeout(500, null);
499+
await setTimeoutAsync(500);
500500

501501
server.respond();
502502

@@ -539,7 +539,7 @@ describe('options.captureUncaught', function () {
539539

540540
rollbar.log('test message', { foo: 'bar' });
541541

542-
await setTimeout(1, null);
542+
await setTimeoutAsync(1);
543543

544544
server.respond();
545545

@@ -567,7 +567,7 @@ describe('options.captureUncaught', function () {
567567

568568
rollbar.log(new Error('test error'), { foo: 'bar' });
569569

570-
await setTimeout(1, null);
570+
await setTimeoutAsync(1);
571571

572572
server.respond();
573573

@@ -601,7 +601,7 @@ describe('options.captureUncaught', function () {
601601

602602
rollbar.error(err, { foo: 'bar' });
603603

604-
await setTimeout(1, null);
604+
await setTimeoutAsync(1);
605605

606606
server.respond();
607607

@@ -649,7 +649,7 @@ describe('options.captureUncaught', function () {
649649
custom.self = custom;
650650
rollbar.error(err, custom);
651651

652-
await setTimeout(1, null);
652+
await setTimeoutAsync(1);
653653

654654
server.respond();
655655

@@ -691,7 +691,7 @@ describe('options.captureUncaught', function () {
691691

692692
rollbar.log(null);
693693

694-
await setTimeout(1, null);
694+
await setTimeoutAsync(1);
695695

696696
server.respond();
697697

@@ -720,7 +720,7 @@ describe('options.captureUncaught', function () {
720720
rollbar.log(error);
721721
rollbar.log(error, { skipFrames: 1 });
722722

723-
await setTimeout(1, null);
723+
await setTimeoutAsync(1);
724724

725725
server.respond();
726726

test/browser.replay.recorder.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import sinon from 'sinon';
55

66
import Recorder from '../src/browser/replay/recorder.js';
77

8-
import { stubRecordFn } from './replay/util/mockRecordFn.js';
8+
import { stubRecordFn } from './replay/util/mockRecordFn.ts';
99

1010
describe('Recorder', function () {
1111
let mockTracing;

test/browser.rollbar.autoInstrument.csp.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import sinon from 'sinon';
33

44
import Rollbar from '../src/browser/rollbar.js';
55

6-
import { setTimeout } from './util/timers.js';
6+
import { setTimeoutAsync } from './util/timers.ts';
77

88
describe('options.autoInstrument', function () {
99
describe('contentSecurityPolicy', function () {
@@ -48,7 +48,7 @@ describe('options.autoInstrument', function () {
4848

4949
document.dispatchEvent(cspEvent);
5050

51-
await setTimeout(100, null);
51+
await setTimeoutAsync(100);
5252

5353
expect(queueStub.called).to.be.true;
5454
const item = queueStub.getCall(0).args[0];

test/browser.rollbar.autoInstrument.fetch.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import sinon from 'sinon';
44
import Rollbar from '../src/browser/rollbar.js';
55

66
import { fakeServer } from './browser.rollbar.test-utils.ts';
7-
import { setTimeout } from './util/timers.js';
7+
import { setTimeoutAsync } from './util/timers.ts';
88

99
describe('options.autoInstrument', function () {
1010
beforeEach(function () {
@@ -80,7 +80,7 @@ describe('options.autoInstrument', function () {
8080

8181
rollbar.log('test'); // generate a payload to inspect
8282

83-
await setTimeout(1, null);
83+
await setTimeoutAsync(1);
8484

8585
server.respond();
8686

@@ -153,7 +153,7 @@ describe('options.autoInstrument', function () {
153153
};
154154

155155
await window.fetch(fetchRequest, fetchInit).then(async (_response) => {
156-
await setTimeout(1, null);
156+
await setTimeoutAsync(1);
157157

158158
server.respond();
159159

@@ -224,7 +224,7 @@ describe('options.autoInstrument', function () {
224224
await window.fetch(fetchRequest, fetchInit).then(async (response) => {
225225
rollbar.log('test'); // generate a payload to inspect
226226

227-
await setTimeout(1, null);
227+
await setTimeoutAsync(1);
228228

229229
server.respond();
230230

test/browser.rollbar.autoInstrument.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { expect } from 'chai';
33
import Rollbar from '../src/browser/rollbar.js';
44

55
import { fakeServer } from './browser.rollbar.test-utils.ts';
6-
import { setTimeout } from './util/timers.js';
6+
import { setTimeoutAsync } from './util/timers.ts';
77

88
describe('options.autoInstrument', function () {
99
beforeEach(function () {
@@ -39,7 +39,7 @@ describe('options.autoInstrument', function () {
3939

4040
rollbar.log('test'); // generate a payload to inspect
4141

42-
await setTimeout(1, null);
42+
await setTimeoutAsync(1);
4343

4444
server.respond();
4545

@@ -69,7 +69,7 @@ describe('options.autoInstrument', function () {
6969

7070
rollbar.log('test'); // generate a payload to inspect
7171

72-
await setTimeout(1, null);
72+
await setTimeoutAsync(1);
7373

7474
server.respond();
7575

test/browser.rollbar.autoInstrument.xhr.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { expect } from 'chai';
33
import Rollbar from '../src/browser/rollbar.js';
44

55
import { fakeServer } from './browser.rollbar.test-utils.ts';
6-
import { setTimeout } from './util/timers.js';
6+
import { setTimeoutAsync } from './util/timers.ts';
77

88
describe('options.autoInstrument', function () {
99
beforeEach(function () {
@@ -60,7 +60,7 @@ describe('options.autoInstrument', function () {
6060
if (xhr.readyState === 4) {
6161
rollbar.log('test'); // generate a payload to inspect
6262

63-
await setTimeout(1, null);
63+
await setTimeoutAsync(1);
6464

6565
server.respond();
6666

@@ -112,7 +112,7 @@ describe('options.autoInstrument', function () {
112112
if (xhr.readyState === 4) {
113113
rollbar.log('test'); // generate a payload to inspect
114114

115-
await setTimeout(1, null);
115+
await setTimeoutAsync(1);
116116

117117
server.respond();
118118

@@ -161,7 +161,7 @@ describe('options.autoInstrument', function () {
161161
if (xhr.readyState === 4) {
162162
rollbar.log('test'); // generate a payload to inspect
163163

164-
await setTimeout(1, null);
164+
await setTimeoutAsync(1);
165165

166166
server.respond();
167167

@@ -214,7 +214,7 @@ describe('options.autoInstrument', function () {
214214
xhr.setRequestHeader('Content-type', 'application/json');
215215
xhr.onreadystatechange = async function () {
216216
if (xhr.readyState === 4) {
217-
await setTimeout(1, null);
217+
await setTimeoutAsync(1);
218218

219219
server.respond();
220220

@@ -230,7 +230,7 @@ describe('options.autoInstrument', function () {
230230
}
231231
};
232232
xhr.send(JSON.stringify({ name: 'bar', secret: 'xhr post' }));
233-
await setTimeout(1, null);
233+
await setTimeoutAsync(1);
234234

235235
server.respond();
236236
});

test/browser.rollbar.test-utils.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,6 @@
33
*/
44

55
import 'nise';
6-
import sinon from 'sinon';
7-
8-
import Rollbar from '../src/browser/core.js';
9-
10-
declare global {
11-
interface Window {
12-
nise: typeof import('nise');
13-
14-
fetch: sinon.SinonStub;
15-
fetchStub: sinon.SinonStub;
16-
17-
rollbar: Rollbar;
18-
server: import('nise').FakeServer;
19-
chrome: { runtime: boolean };
20-
_rollbarURH: ((evt: PromiseRejectionEvent) => void) & {
21-
belongsToShim?: boolean;
22-
};
23-
}
24-
}
256

267
export const { fakeServer } = window.nise;
278

0 commit comments

Comments
 (0)