Skip to content

Migrate browser.core.test.js to ts, update sinon, add nise, fix types#1445

Merged
matux merged 5 commits intomasterfrom
matux/migrate-test-js-to-ts-2
Nov 25, 2025
Merged

Migrate browser.core.test.js to ts, update sinon, add nise, fix types#1445
matux merged 5 commits intomasterfrom
matux/migrate-test-js-to-ts-2

Conversation

@matux
Copy link
Contributor

@matux matux commented Nov 24, 2025

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:

  • To support TS, I had to update sinon to the latest version.
    • Latest sinon doesn't include the ability to create fake servers, it's now in a separate library that I had to add: sinonjs/nise.
    • This library is commonjs only, so I had to do some trickery to import it.
  • Fixed all instances of var and turned them into const/let
  • Fixed multiple type issues in index.d.ts unearthed by TypeScript
    • Changed a TS example to use person the way it's supposed to (it wasn't working before)
  • Many other browser test JS files were turned into TS but it was only a rename, had to add // @ts-nocheck on them (and enable it in eslint.config.js)
  • Changed vscode settings so they use the typescript version installed by the sdk
  • More stuff I probably am not remembering

@matux matux requested a review from Copilot November 24, 2025 21:29
@matux matux self-assigned this Nov 24, 2025
@matux matux changed the title Migrate browser.core.test.js to ts, update sinon, add nise, fix types Migrate browser.core.test.js to ts, update sinon, add nise, fix types Nov 24, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 sinon from v8 to v21 and added nise v6 for fake server support
  • Migrated multiple browser test files to TypeScript with @ts-nocheck directives
  • 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"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tell vscode to use the sdk's typescript.

id: '12345',
name: 'Test User',
email: 'user@test.com',
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't working before this update.

Comment on lines 11 to 20
declare global {
interface Window {
rollbar: Rollbar;
server: import('nise').FakeServerStatic;
chrome: { runtime: boolean };
_rollbarURH: ((evt: PromiseRejectionEvent) => void) & {
belongsToShim?: boolean;
};
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 }],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Temporary until all new TS tests are migrated

Comment on lines +37 to +50
// 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;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't find a way not to repeat this from Rollbar.Components here.

Comment on lines +120 to +124
"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",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@matux matux requested a review from waltjones November 25, 2025 16:43
@matux matux merged commit 382f68a into master Nov 25, 2025
7 checks passed
@matux matux deleted the matux/migrate-test-js-to-ts-2 branch November 25, 2025 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants