nodejs / node

Node.js JavaScript runtime ✨🐢🚀✨
https://nodejs.org
Other
106.53k stars 29.03k forks source link

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

Open AugustinMauroy opened 5 months ago

AugustinMauroy commented 5 months ago

Affected URL(s)

https://nodejs.org/docs/latest-v20.x/api/test.html#mocking

Description of the problem

On docs there missing explains about how to mock Error and catch it with throws.

cjihrig commented 5 months ago

You haven't provided enough information for a meaningful bug report. You're creating a mock, but not showing where/how you expect that mock to be triggered. I'm guessing it's supposed to be somewhere in getBitness(), but that code is not provided.

AugustinMauroy commented 5 months ago

You haven't provided enough information for a meaningful bug report. You're creating a mock, but not showing where/how you expect that mock to be triggered. I'm guessing it's supposed to be somewhere in getBitness(), but that code is not provided.

I had remove my code snippet because it's isn't right. And real subject of this issue is example of mocking Error with nod test-runner.

cjihrig commented 5 months ago

The docs can be improved, but until then, here are a couple examples in the tests.

AugustinMauroy commented 5 months ago

How to work on docs? I would like to work on this issue.

cjihrig commented 5 months ago

The docs for the test runner are in doc/api/test.md.

AugustinMauroy commented 5 months ago

ok thanks !