-
-
Notifications
You must be signed in to change notification settings - Fork 688
Open
Labels
enhancementNew feature or requestNew feature or request
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
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request