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
This would solve...
More quickly understanding which mocked endpoint is not matching on
MockNotMatchedError🤔☝️ what endpoint is this not matching for???
The implementation should look like...
In
mock-utils.js>getMockDispatch, there are a series ofmatchedMockDispatcheschecks.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 theMockNotMatchedErrorsource.For example, if we don't match the request method, the error could be:
Then, in our original error message, we'd know our
POSTrequest isn't matchingon path /api/channels/123/messages