Skip to content

Fix sinon types in ApprovalController tests#397

Merged
Gudahtt merged 2 commits intodevelopfrom
fix-approval-controller-test-sinon-types
Mar 16, 2021
Merged

Fix sinon types in ApprovalController tests#397
Gudahtt merged 2 commits intodevelopfrom
fix-approval-controller-test-sinon-types

Conversation

@Gudahtt
Copy link
Copy Markdown
Member

@Gudahtt Gudahtt commented Mar 16, 2021

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.

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.
@Gudahtt Gudahtt requested a review from a team as a code owner March 16, 2021 14:21
@Gudahtt Gudahtt merged commit da2a17b into develop Mar 16, 2021
@Gudahtt Gudahtt deleted the fix-approval-controller-test-sinon-types branch March 16, 2021 17:26
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>
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