Fix sinon types in ApprovalController tests#397
Merged
Conversation
The types used in the ApprovalController tests for sinon tests were wrong. `typeof sinon.spy` was being used to get the spy type, but this returns the type of the `spy()` function, not of a spy instance. Instead the type `SinonSpy` is used instead. This type is provided by the `@types/sinon` package. For some reason it seems to provide more correct type information than `ReturnType<typeof sinon['spy']>`, though I'm not sure why. The sinon import was updated to use `import` rather than `require` as well, as TypeScript seemingly doesn't type anything that is imported using `require`. This introduced two new type errors caused by us using private methods in the test. I've silenced these errors for now by casting to `any`, but we should update these tests later to stop relying upon internals.
brad-decker
approved these changes
Mar 16, 2021
MajorLift
pushed a commit
that referenced
this pull request
Oct 11, 2023
The types used in the ApprovalController tests for sinon tests were wrong. `typeof sinon.spy` was being used to get the spy type, but this returns the type of the `spy()` function, not of a spy instance. Instead the type `SinonSpy` is used instead. This type is provided by the `@types/sinon` package. For some reason it seems to provide more correct type information than `ReturnType<typeof sinon['spy']>`, though I'm not sure why. The sinon import was updated to use `import` rather than `require` as well, as TypeScript seemingly doesn't type anything that is imported using `require`. This introduced two new type errors caused by us using private methods in the test. I've silenced these errors for now by casting to `any`, but we should update these tests later to stop relying upon internals.
MajorLift
pushed a commit
that referenced
this pull request
Oct 11, 2023
The types used in the ApprovalController tests for sinon tests were wrong. `typeof sinon.spy` was being used to get the spy type, but this returns the type of the `spy()` function, not of a spy instance. Instead the type `SinonSpy` is used instead. This type is provided by the `@types/sinon` package. For some reason it seems to provide more correct type information than `ReturnType<typeof sinon['spy']>`, though I'm not sure why. The sinon import was updated to use `import` rather than `require` as well, as TypeScript seemingly doesn't type anything that is imported using `require`. This introduced two new type errors caused by us using private methods in the test. I've silenced these errors for now by casting to `any`, but we should update these tests later to stop relying upon internals.
Mrtenz
pushed a commit
that referenced
this pull request
Oct 16, 2025
Moved the compatibility test into it's own workflow. This implements the change described here MetaMask/metamask-module-template#269, ensuring that the compatibility test continues to provide value in identifying issues, but does not hold up individual PRs that do not introduce these issues.
Mrtenz
pushed a commit
that referenced
this pull request
Oct 16, 2025
This is the release for version 17.1.0. ``` 4e74bb9 feat: add RPC methods described in (revised) EIP-7715 (#396) 0a66477 Run compatibility test only in main branch. (#397) ``` --------- Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Jeff Smale <6363749+jeffsmale90@users.noreply.github.com> Co-authored-by: Elliot Winkler <elliot.winkler@gmail.com>
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.
The types used in the ApprovalController tests for sinon tests were wrong.
typeof sinon.spywas being used to get the spy type, but this returns the type of thespy()function, not of a spy instance.Instead the type
SinonSpyis used instead. This type is provided by the@types/sinonpackage. For some reason it seems to provide more correct type information thanReturnType<typeof sinon['spy']>, though I'm not sure why.The sinon import was updated to use
importrather thanrequireas well, as TypeScript seemingly doesn't type anything that is imported usingrequire.This introduced two new type errors caused by us using private methods in the test. I've silenced these errors for now by casting to
any, but we should update these tests later to stop relying upon internals.