Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

doc: add examples for mocking errors with throws#60698

Open
rish106-hub wants to merge 1 commit intonodejs:mainnodejs/node:mainfrom
rish106-hub:doc-mock-error-examplerish106-hub/node:doc-mock-error-exampleCopy head branch name to clipboard
Open

doc: add examples for mocking errors with throws#60698
rish106-hub wants to merge 1 commit intonodejs:mainnodejs/node:mainfrom
rish106-hub:doc-mock-error-examplerish106-hub/node:doc-mock-error-exampleCopy head branch name to clipboard

Conversation

@rish106-hub
Copy link

Fixes #52357

Added documentation and examples showing how to mock functions that throw errors and test them using assert.throws().

This addresses the missing explanation in the test runner mocking documentation about how to mock errors and catch them with throws.

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/test_runner

@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. test_runner Issues and PRs related to the test runner subsystem. labels Nov 13, 2025
@JakobJingleheimer
Copy link
Member

Hiya! Thanks for putting this together, but I think it's not really necessary. If anything, I think it would be more appropriate in the learn article: https://nodejs.org/learn/en/test-runner/mocking

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc Issues and PRs related to the documentations. test_runner Issues and PRs related to the test runner subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs(test-runner): missing example and explain about how to mock error

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.