forcedotcom / forcedotcom/ts-sinon
Stubbing interfaces/objects seems to not support overriding members with null value
- Dominant language
- TypeScript
- Stars
- 1
- Forks
- 0
- Avg merge
- 6m
- Merged PRs (30d)
- 2
Description
See - https://github.com/forcedotcom/ts-sinon/blob/6dcb6055fd9064cd42159ab38e94be7a8f2dcab6/src/index.ts#L34
Currently, the workflow of stubbing an interface with optional members does not really seem to work as expected. For example, if I have an interface that is similar to this:
```
interface Test {
testMember: MemberObject;
}
```
Where `MemberObject` is an arbitrary object, calling the following does not override the value of the stubbed object with null as one may expect:
`tsSinon.stubInterface(sinon, { testMember: null })`
For my testing purposes, I'd like to verify that specific members of an object exist and are non-null, however currently this override is ignored, and proceeds to create a stub for this, which seems like incorrect behavior:
https://github.com/forcedotcom/ts-sinon/blob/6dcb6055fd9064cd42159ab38e94be7a8f2dcab6/src/index.ts#L43
It falls through to this because the call to `makeProxyGet` hardcodes stubMissing === true from the call via `stubInterface`. As such, overriding a member with a null value is not possible, and will incorrectly return a stub.
Is this extension library capable of supporting this, or is this in fact an issue with the current implementation?
Thank you!
Contributor guide
Assessment
This issue has not been assessed yet.