Migrate browser.core.test.js to ts, update sinon, add nise, fix types#1445
Migrate browser.core.test.js to ts, update sinon, add nise, fix types#1445
browser.core.test.js to ts, update sinon, add nise, fix types#1445Conversation
browser.core.test.js to ts, update sinon, add nise, fix typesbrowser.core.test.js to ts, update sinon, add nise, fix types
There was a problem hiding this comment.
Pull request overview
This PR migrates browser test files to TypeScript, updates the sinon library to version 21, and introduces nise as a separate dependency for fake server functionality. Key changes include replacing var declarations with const/let, fixing type issues in index.d.ts, and configuring TypeScript to handle the new setup.
- Updated
sinonfrom v8 to v21 and addednisev6 for fake server support - Migrated multiple browser test files to TypeScript with
@ts-nocheckdirectives - Fixed type definitions and added proper TypeScript configuration
Reviewed changes
Copilot reviewed 24 out of 26 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Updated sinon to v21, added nise v6 and @types/nise dependencies |
| tsconfig.test.json | Added sinon types and TypeScript import extensions support |
| test/browser.rollbar.test-utils.ts | Created utility to import and export nise fakeServer with proper type declarations |
| test/browser.core.test.ts | Migrated to TypeScript with proper type declarations and nise integration |
| test/browser.*.test.ts (multiple) | Added @ts-nocheck directive and replaced var with const/let |
| test/examples/*.test.js | Replaced sinon.createFakeServer() with fakeServer.create() |
| eslint.config.js | Enabled ts-nocheck directive in TypeScript files |
| .vscode/settings.json | Configured VS Code to use project's TypeScript version |
| examples/react-19-ts-components/src/App.tsx | Added person configuration to demonstrate proper API usage |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "files.trimTrailingWhitespace": true, | ||
| "prettier.useEditorConfig": false | ||
| "prettier.useEditorConfig": false, | ||
| "typescript.tsdk": "node_modules/typescript/lib" |
There was a problem hiding this comment.
Tell vscode to use the sdk's typescript.
| id: '12345', | ||
| name: 'Test User', | ||
| email: 'user@test.com', | ||
| }, |
There was a problem hiding this comment.
This wasn't working before this update.
| declare global { | ||
| interface Window { | ||
| rollbar: Rollbar; | ||
| server: import('nise').FakeServerStatic; | ||
| chrome: { runtime: boolean }; | ||
| _rollbarURH: ((evt: PromiseRejectionEvent) => void) & { | ||
| belongsToShim?: boolean; | ||
| }; | ||
| } | ||
| } |
There was a problem hiding this comment.
Will see next if I can put this somewhere more general so I don't have to copy/paste on every test file.
|
|
||
| // disabled for now | ||
| '@typescript-eslint/no-explicit-any': 'off', | ||
| '@typescript-eslint/ban-ts-comment': ['error', { 'ts-nocheck': false }], |
There was a problem hiding this comment.
Temporary until all new TS tests are migrated
| // Components | ||
|
|
||
| public telemeter?: TelemeterType; | ||
| public instrumenter?: InstrumenterType; | ||
| public wrapGlobals?: WrapGlobalsType; | ||
| public scrub?: ScrubType; | ||
| public truncation?: TruncationType; | ||
| public tracing?: TracingType; | ||
| /** | ||
| * Replay component for session recording. | ||
| * Only available when using replay bundles (rollbar.replay.*). | ||
| * Use `import Rollbar from 'rollbar/replay'` to access. | ||
| */ | ||
| public replay?: ReplayType; |
There was a problem hiding this comment.
Couldn't find a way not to repeat this from Rollbar.Components here.
| "nise": "^6.1.1", | ||
| "nock": "^11.9.1", | ||
| "node-libs-browser": "^0.5.2", | ||
| "prettier": "^3.6.2", | ||
| "sinon": "^8.1.1", | ||
| "sinon": "^21.0.0", |
There was a problem hiding this comment.
Tried to keep the old sinon version but I couldn't, then starting sinon 9+, creating fake servers is done using their library called nise.
Description of the change
This PR does a ton of things that I couldn't separate into multiple steps because it's all quantumly entangled:
sinonto the latest version.sinondoesn't include the ability to create fake servers, it's now in a separate library that I had to add:sinonjs/nise.varand turned them intoconst/letindex.d.tsunearthed by TypeScriptpersonthe way it's supposed to (it wasn't working before)// @ts-nocheckon them (and enable it ineslint.config.js)