MockProvider currently offers an option showWarnings with the following description:
When a request fails to match a mock, a warning is logged to the console to indicate the mismatch. Set this to false to silence these warnings.
The default value is true.
The problem is that it's insufficient for robust testing because showing a warning doesn't fail the tests.
For reliable integration tests, no network request should actually hit the network. A warning is easily missed in the tests output logs and unfortunately we're shipping that code because the tests passed while we didn't want them to. This often leaves a plethora of garbage in the tests output logs that we need to fix after the fact...
What we need is an option to fail the tests on such occasion:
throwExceptionOnRequestMatchMiss
When a request fails to match a mock, throws an exception. This will allow your test framework to fail a test and fix the problem before it's pushed to production. Set to true to activate this functionality.
The default value is false.
I know such feature exists in MSW (Mocked Server Worker) and other solutions for mocking requests at the network layer. It would be a nice addition to the MockedProvider.
MockProvider
currently offers an optionshowWarnings
with the following description:The problem is that it's insufficient for robust testing because showing a warning doesn't fail the tests.
For reliable integration tests, no network request should actually hit the network. A warning is easily missed in the tests output logs and unfortunately we're shipping that code because the tests passed while we didn't want them to. This often leaves a plethora of garbage in the tests output logs that we need to fix after the fact...
What we need is an option to fail the tests on such occasion:
I know such feature exists in MSW (Mocked Server Worker) and other solutions for mocking requests at the network layer. It would be a nice addition to the
MockedProvider
.