Properly surface non-serializable errors in tests #212
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
AVA runs tests in separate processes, and it uses IPC to communicate them back to the main process for logging and reporting. If an error isn't serializable, then the IPC fails and we end up not being able to see the actual error or even what test failed which is as delightful as it sounds. The main culprit of this has been Axios when there's a Nock error.
This PR improves the situation by adding an Axios response interceptor and sanitizing any errors so that they're serializable. The heavy lifting on the sanitization is done by the serialize-error package which I've added as a dev dependency. It cleans up issues like functions, buffers, and circular references which are the common culprits of non-serializability.
If you want to test this yourself, you can remove fixtures with
rm test/fixtures/sdk.test.ts.json
and then runnpm run test
to run the tests. You'll get the opaque error onmain
and the real error on this branch.