-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Expect calls custom inspect()
function unexpectedly
#4478
Comments
inspect()
function causing tests to breakinspect()
function unexpectedly
As mentioned this looks to be |
We should probably just disable it by default on our side. PR welcome. |
I will see what I can do later today 👍🏻 |
I gave this a go and the contributing guide wasn't getting me anywhere, things were erroring. So I decided to try go in blind and discovered the following which suggests we cannot turn of the custom inspect for this specific case:
This appears to be the only code path that triggers |
There is a test.chaiConfig property in the config that can influence inspect options I think, but I'm not sure. |
I followed the stack through these functions (now with links to The final function inspect(obj, showHidden, depth, colors) {
var options = {
colors: colors,
depth: (typeof depth === 'undefined' ? 2 : depth),
showHidden: showHidden,
truncate: config.truncateThreshold ? config.truncateThreshold : Infinity,
};
return loupe.inspect(obj, options);
} So I don't think a chai config will take effect, unless its some magic stuff. |
Describe the bug
Any object that has an
inspect()
function will be called when passed toexpect()
. If this function happens to expect an argument, for exampleinspect(fn: () => void)
then the test will fail for the wrong reason. This doesn't seem to mentioned in the api and means you need to guard around this currently by doing more targeted tests.Reproduction
Using
vitest@^0.34.0
(including beta1.0.0
releases) the following test:Will output as expected:
This appears to be down to
loupe
but again, this is unexpected.System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: