-
Notifications
You must be signed in to change notification settings - Fork 58
Add Expectation.extend for custom matchers #62
Conversation
Rationale: For example, this would allow a mocking library to add its own expectation for spies or would allow the following issues to be closed (in favor of a "TestEZ-extended"-like library) |
Still some open questions that could be answered now or at a later date:
|
After discussing this some earlier, I think we'll want this much sooner than we'll be able to commit to replacing the expectation syntax. As this PR is fairly old at this point and will likely require some rework anyway: One thing I'd like to see with something like this is the ability for these to be defined in a scoped way (e.g. in init.spec.lua files instead of in the starter scripts). That may be a break from the original API, but I think it alleviates a lot of concerns about conflicting overrides. If there's an issue, it'll be because you overrode your own stuff, not because some other unrelated code did. It also makes allowing overriding the builtin expectations a lot safer if that's something we want (I could see either way on that). Unfortunately, the way Expectation is written, making it so that the changes are scoped will be a bit trickier. You'd need to store the extensions in the test plan's tree (or something parallel to that) and pass them along as needed. |
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
Closing in favor of #142 |
Expectation.extend
which allow projects to add their own matchers to TestEZ.pass
and a stringmessage
Heavily influenced by https://jestjs.io/docs/en/expect#expectextendmatchers