Closed coolsoftwaretyler closed 3 months ago
hey @coolsoftwaretyler, I'll work on this one ✋
Hi @JuanJo4, that's great! Let me know if you need a hand.
I think I'd slightly prefer the approach where we rename the function to be like, mstFail
, so we don't collide with Jest.
I think I'd slightly prefer the approach where we rename the function to be like,
mstFail
, so we don't collide with Jest.
agreed, and I decided to use a class instead of a function class MstError extends Error
, it seems more natural to me to throw an Error and not a function.
I'll push a PR soon, not sure how to write a test for this though, any suggestions?
I also have a slight preference for a function here, I assume renaming the function and renaming its call sites is easier that way, but I'm happy to consider the class if it offers some other advantage.
As for a test, I would exercise the behavior - what parameters do we ask for, and what do we expect to happen? Maybe spy on whatever console method we use in the failures.
We've run into this problem a few times, where TypeScript thinks
fail
is a Jest function, so it doesn't send an error when we're missing an import.Here's a recent PR that fixes one instance of the problem:
https://github.com/mobxjs/mobx-state-tree/pull/2137
And we've seen it before: https://github.com/mobxjs/mobx-state-tree/issues/1989
I think this is a great issue for someone who is new to the project. We need to make sure we don't have missing imports, so we should either:
fail
needs to be defined (perhaps using folder paths to differentiate, since tests are separate)fail
to something that doesn't collide with Jest, likemstFail
or somethingEither way, we should be able to verify we aren't missing any more
fail
imports with linting.