Skip to content

test(sample-controllers): demonstrate messenger interactions - #10013

Open
revisedbytom wants to merge 1 commit into
MetaMask:mainfrom
revisedbytom:test-messenger-interactions
Open

test(sample-controllers): demonstrate messenger interactions#10013
revisedbytom wants to merge 1 commit into
MetaMask:mainfrom
revisedbytom:test-messenger-interactions

Conversation

@revisedbytom

Copy link
Copy Markdown

Explanation

Adds focused examples to the sample controller tests showing how to:

  • spy on a controller messenger and assert an external action call
  • subscribe to a controller event and assert the published state

This keeps production behavior unchanged and addresses #6766.

References

Fixes #6766

Changelog

No changelog entry is needed because this only changes test examples.

Checklist

  • Focused sample-controller tests pass (28 tests)
  • Modified files pass ESLint and oxfmt checks
  • The monorepo and sample-controller package build successfully

Test commands

  • corepack yarn workspace @metamask/sample-controllers run jest --no-coverage packages/sample-controllers/src/sample-gas-prices-controller.test.ts packages/sample-controllers/src/sample-petnames-controller.test.ts
  • corepack yarn eslint packages/sample-controllers/src/sample-gas-prices-controller.test.ts packages/sample-controllers/src/sample-petnames-controller.test.ts
  • corepack yarn oxfmt --check packages/sample-controllers/src/sample-gas-prices-controller.test.ts packages/sample-controllers/src/sample-petnames-controller.test.ts
  • corepack yarn build

Made with Cursor

Show how controller tests can assert delegated action calls and published state events without changing production behavior.

Co-authored-by: Cursor <cursoragent@cursor.com>
@revisedbytom
revisedbytom requested a review from a team as a code owner August 29, 2026 14:59
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.

Demonstrate more examples of testing messenger interactions in sample controllers

1 participant