sinonjs / sinon

Test spies, stubs and mocks for JavaScript.
https://sinonjs.org/
Other
9.67k stars 769 forks source link

Link to createStubInstance util.md docs in stubs.md #2577

Closed DanKaplanSES closed 10 months ago

DanKaplanSES commented 10 months ago

Purpose (TL;DR) - mandatory

The Utilities documentation contains valuable information about createStubInstance, but I didn't see any way to know that unless you happen to have already viewed the Utilities page.

Alternatively, could it make sense to move all of the createStubInstance docs into stubs.md? For me, that's where I would expect to find everything there is to know about createStubInstance, or at least the behavior it provides.

How to verify - mandatory

  1. Check out this branch
  2. npm install

Checklist for author

codecov[bot] commented 10 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (adcf936) 96.02% compared to head (15b2b33) 96.02%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #2577 +/- ## ======================================= Coverage 96.02% 96.02% ======================================= Files 40 40 Lines 1912 1912 ======================================= Hits 1836 1836 Misses 76 76 ``` | [Flag](https://app.codecov.io/gh/sinonjs/sinon/pull/2577/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sinonjs) | Coverage Δ | | |---|---|---| | [unit](https://app.codecov.io/gh/sinonjs/sinon/pull/2577/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sinonjs) | `96.02% <ø> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sinonjs#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

fatso83 commented 10 months ago

Alternatively, could it make sense to move all of the createStubInstance docs into stubs.md

I get it from the name, but it's not a method on the stubs object, and it's mostly similar by name only. If it should be moved somewhere, I guess it would be on the sandbox, if anything. But linking from different docs is highly effective and we should only do it more than we do.

I know the docs are far from perfect, but it's what we have now. I know @mroderick is cooking on something, but I don't know the state of it, just that it probably will be different in some way (not sure of the goals ATM, just that it should be better :) ).

DanKaplanSES commented 10 months ago

@fatso83

I guess it would be on the sandbox, if anything. But linking from different docs is highly effective and we should only do it more than we do.

Hm, that's interesting. Until your comment on this issue, I didn't realize this was documented in three places. Should I submit a PR to add links to the other docs in these places?

fatso83 commented 10 months ago

It doesn't mean that the docs are correct, though ... I see that the docs say that there is a difference between the sinon. createStubInstance and sandbox.createStubInstance, but that might be leftovers from the Sinon 1.x days. As of Sinon 2.0, the default sinon instance is a sandbox. Cannot see how they are different (please test if you think otherwise)? So I'd rather just have the docs in one place and just link to that.

DanKaplanSES commented 10 months ago

So I'd rather just have the docs in one place and just link to that.

I think I understand but I'm not 100% sure. In other words, the sandbox documentation should be the one and only place to document createStubInstance and the stub/util documents should mostly link to it.