Skip to content

Remove ESLint jest/valid-expect-in-promise - #426

Merged
Gudahtt merged 6 commits into
developfrom
refactor-jest-async-await
Apr 7, 2021
Merged

Remove ESLint jest/valid-expect-in-promise#426
Gudahtt merged 6 commits into
developfrom
refactor-jest-async-await

Conversation

@astarinmymind

Copy link
Copy Markdown
Contributor

This PR refactors the way the tests catch errors. Currently they are wrapped in promises, but instead it can be refactored to use a jest trick of await expect(function).rejects.toThrow('error message'). Using this trick, we can remove this lint rule.

@astarinmymind
astarinmymind requested a review from a team as a code owner March 23, 2021 03:44

@Gudahtt Gudahtt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Mostly good! The Transaction controller tests need some adjustment

Comment thread src/assets/AssetsController.test.ts Outdated
Comment thread src/transaction/TransactionController.test.ts Outdated
Comment thread src/transaction/TransactionController.test.ts
Gudahtt
Gudahtt previously approved these changes Mar 25, 2021

@Gudahtt Gudahtt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

Lots more examples left where an expect call is in an event handler that may or may not finish before the test ends, but we can fix that separately. I'll add another checklist item for that.

controller.cancelTransaction(controller.state.transactions[0].id);
result.catch((error) => {
expect(error.message).toContain('User rejected the transaction');
resolve('');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: we don't need to pass anything to resolve here.

Suggested change
resolve('');
resolve();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Bah. I committed this, but now the test fails because the type needs to be adjusted. I'm going to undo this for now - we can fix it some other time.

@Gudahtt
Gudahtt force-pushed the refactor-jest-async-await branch from 1382ec8 to 56c1c91 Compare April 7, 2021 16:15
@Gudahtt

Gudahtt commented Apr 7, 2021

Copy link
Copy Markdown
Member

I decided to go ahead and merge this now, to reduce the chance of future conflicts

@Gudahtt
Gudahtt merged commit 8adc09b into develop Apr 7, 2021
@Gudahtt
Gudahtt deleted the refactor-jest-async-await branch April 7, 2021 16:18
Mrtenz pushed a commit that referenced this pull request Oct 16, 2025
…d core monorepo (#420)" (#423) (#426)

This reverts commit d8129a6 (Reapplies
d10c455)

<!--
Thanks for your contribution! Take a moment to answer these questions so
that reviewers have the information they need to properly understand
your changes:

* What is the current state of things and why does it need to change?
* What is the solution your changes offer and how does it work?

Are there any issues or other links reviewers should consult to
understand this pull request better? For instance:

* Fixes #12345
* See: #67890
-->


<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Overhauls the dev toolchain: upgrades ESLint to v9 with new
configs/plugins, moves to TypeScript 5.x, adds
TypeDoc/depcheck/ts-bridge/ATTW tooling, updates Prettier to v3, and
refreshes dependencies.
> 
> - **Dev toolchain sync/upgrade**
> - **ESLint 9**: Bump core and configs (MetaMask v14), migrate
plugins/resolvers (e.g., `eslint-plugin-import-x`,
`eslint-import-resolver-typescript`), and update related utilities.
> - **TypeScript 5.x**: Update TypeScript, `typescript-eslint` (v8),
`ts-node`, and supporting packages.
> - **Formatting & docs**: Upgrade **Prettier** to v3 and
`prettier-plugin-packagejson`; add **TypeDoc**.
> - **New tooling**: Add `@arethetypeswrong/cli`, `@ts-bridge/cli`, and
**depcheck** for dependency hygiene.
> - **Dependencies**: Broad dependency updates and lockfile refresh to
align with core template.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
5ef56a47b1975d8ded4b528f0e5bd76585e4bac1. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
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