testdouble / testdouble/testdouble.js
add `withContext` option
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.4k
- Forks
- 140
- Avg merge
- 22h
- Merged PRs (30d)
- 1
Description
Proposal: allow test double stubbing/verification configuration to specify the value of this that's bound when the test double function is called.
td.when(myTd(), {withContext: window})).thenReturn(5)
myTd() // undefined
myTd.bind(window)() // 5
And for verify:
myTd()
td.verify(myTd(), {withContext: window})) // blows up
myTd.bind(window)()
td.verify(myTd(), {withContext: window})) // passes
Also, argument matchers should be supported:
myTd.bind(new Promise())()
td.verify(myTd(), {withContext: td.matchers.argThat(arg => arg instanceof Promise)})) // passes
Thoughts?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the existing td.when and td.verify behavior, then inspect how argument matchers are handled. The change is done when stubbing and verification can match the bound this value through withContext, including matcher support for the context object, with tests covering the examples in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- testing-qa
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100