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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add typeof assertion #762
Conversation
鉁旓笍 Deploy Preview for vitest-dev ready! 馃敤 Explore the source changes: f6a09f1 馃攳 Inspect the deploy log: https://app.netlify.com/sites/vitest-dev/deploys/620c0c5ce4c3060008576559 馃槑 Browse the preview: https://deploy-preview-762--vitest-dev.netlify.app |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You would need to add docs to api/index.md
i think
And test should be somewere in the test/core/test
馃憖
I think it is accesible with: import { assert } from 'chai'
assert.typeOf() |
Co-authored-by: Vladimir <sheremet-va@users.noreply.github.com>
Tested this, but it's not so accurate and the negation with |
@sheremet-va Ready for a second review 馃殌 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thank you for PR!
Nice! About the name, shouldn't it be
because it is
So, the type of actual is string It is different than for |
Yes and no, cause there is the real |
I think that every other API in expect reads well. IMO, even if some users may initially reach out |
Would you be at least satisfied with an alias? |
For reference, regarding the naming in chai, there it is
but that reads well: type of 'tea' is 'string' |
I like the current version because it is consistent with toBeInstanceOf |
But it isnt consistent to me 馃
the Grammarly complains for "Expect something to be type of string". And the casing, TypeOf instead of typeof also affects here. Imagine that |
|
I'd vote for |
This adds a new assertion that replaces
expect(typeof actual).toBe('string')
withexpect(actual).toBeTypeOf('string')
Please let me know where I need to add docs and/or tests, I'm very unfamiliar with the structure of the repo 馃槄
Edit:
Somehow there is a chai
typeOf
https://www.chaijs.com/api/assert/#method_typeofBut not sure how or if this is in any way accessible from vitest