Improve mock error breadcrumbs
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 880
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 68
Description
This would solve...
More quickly understanding which mocked endpoint is not matching on MockNotMatchedError
MockNotMatchedError: Mock dispatch not matched for method 'POST': subsequent request to origin https://discord.com was not allowed (net.connect disabled)
🤔☝️ what endpoint is this not matching for???
The implementation should look like...
In mock-utils.js>getMockDispatch, there are a series of matchedMockDispatches checks.
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path }) => matchValue(path, resolvedPath))
if (matchedMockDispatches.length === 0) {
throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`)
}
// Match method
matchedMockDispatches = matchedMockDispatches.filter(({ method }) => matchValue(method, key.method))
if (matchedMockDispatches.length === 0) {
throw new MockNotMatchedError(`Mock dispatch not matched for method '${key.method}'`)
}
If the first check passes, we know we've matched resolvedPath. Therefore, we can add this to the error messages in subsequent checks so that its easier to track down the MockNotMatchedError source.
For example, if we don't match the request method, the error could be:
throw new MockNotMatchedError(`Mock dispatch not matched for method '${key.method}' on path '${resolvedPath}'`)
Then, in our original error message, we'd know our POST request isn't matching on path /api/channels/123/messages
Contributor guide
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 in mock-utils.js at getMockDispatch and follow the matchedMockDispatches path and method checks. Update the later MockNotMatchedError messages so they include the already matched resolvedPath; done when a method mismatch identifies the unmatched endpoint, such as /api/channels/123/messages.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- testing-qa
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100