codymikol / karma-webpack

Karma webpack Middleware
MIT License
829 stars 222 forks source link

WIP: feat(validation): improve error handling on invalid karma configuration. #457

Closed codymikol closed 3 years ago

codymikol commented 3 years ago

This PR contains a:

Motivation / Use-Case

So this is currently a work in progress for the next branch and I'd like to get some feedback before moving forward. Using the "next" branch, I ran into a few problem with weird stack trace errors that had me jumping through hoops to figure out what was wrong, the first being that my karma configuration needed "webpack" inside of its frameworks array.

This introduces a simple validation service that can be used to ensure that these prerequisites are met and return a more helpful error message if that is not the case.

Some questions I have before going forward

  1. Does this seem like a worthwhile endeavor?
  2. What other pieces of validation should I consider in this module
  3. is throwing an error the appropriate way to handle these kinds of failures? I don't really like the idea of throwing errors, but as we are running in the context of karma, I don't see any better way to stop execution and report in any kind of fail fast manner.
  4. (more of a comment) I also have some minor refactors in here that I don't plan on including in this merge request, such as moving the hash service out, I plan to put this into another mr eventually.

Breaking Changes

I'm currently under the impression that with V5, these requirements will apply to everyone across the board, but if that is not the case, perhaps warnings might be more appropriate.

Additional Info

codymikol commented 3 years ago

Another thought is that we could verify compatibility with the currently used version of karma