-
-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support ambiguous property types on mocked interfaces #248
Conversation
Very interesting! 😍 Feel free to merge when you feel like it's ready. |
I'm aware of the failing test - currently trying to think how to solve it. |
I added a folder to verify and test the compatibility with different test runners. I wanted to make sure that the new uncaught exception gets reported correctly in different test runners - I added checks for the most popular ones. |
This is the test output inside the npm test
> [email protected] test
> node --require tsx/cjs --test test/**
▶ Verifies test runner compatibility
▶ ava
✔ reports the uncaught Substitute exception (963.726083ms)
▶ ava (964.909625ms)
▶ jest
✔ reports the uncaught Substitute exception (1994.183541ms)
▶ jest (1994.437125ms)
▶ mocha
✔ reports the uncaught Substitute exception (476.041541ms)
▶ mocha (476.190667ms)
▶ nodejs
✔ reports the uncaught Substitute exception (419.588625ms)
▶ nodejs (419.755291ms)
▶ vitest
✔ reports the uncaught Substitute exception (811.546333ms)
▶ vitest (811.702708ms)
▶ Verifies test runner compatibility (4667.739583ms)
ℹ tests 5
ℹ suites 6
ℹ pass 5
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 4740.15625 |
Another great PR! I think I'll have mine ready soon too, and then we can ship v2.0! 😍 |
Fixes #178
This allows mocking callable interfaces. See details in the linked issue.
This also solves a known issue where ambiguous property types of an interface couldn't be asserted (a property that can called as a method and a property).
The implementation is not ideal, but it works and avoids suppressing a valid expectation.
By deferring the exception we can cover this case as well, with the drawback that it escapes the context scope and bubbles up to the main context, resulting in a
uncaughtException
.E.g