-
-
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
expectTypeOf - Tests passes even though there are errors #3425
Comments
Also, watch mode doesn't seem to register changes to the file, i.e. it doesn't reload It reports in the console |
I'm not sure as I only did quick tests, but deep nesting also seems to pass the tests for different types although it should throw an error. PassesThis passes the test, but it shouldn't. import { expectTypeOf } from 'vitest'
type Test = {
object: {
object: {
number: number
string: string
boolean: boolean
object: {
number: number
string: string
boolean: boolean
}
}
}
}
type TestNotEqual = {
object: {
object: {
number?: number
object?: {
number?: number
}
}
}
}
expectTypeOf<Test>().toEqualTypeOf<TestNotEqual>() // this passes the test and does not report an error Not PassingThis doesn't pass the test, but that's expected. As if it recursively checks only the first or second level? import { expectTypeOf } from 'vitest'
type Test = {
object: {
string: string
object: {
object: {
number: number
}
}
}
}
type TestNotEqual = {
object: {
number: number // registers the number as an error since it should be a string, which is expected
object: {
object: {
number: number
}
}
}
}
expectTypeOf<Test>().toEqualTypeOf<TestNotEqual>() // this fails the test and throws an error |
Your tsconfig doesn't include "test" folder: - "include": ["src"],
+ "include": ["src", "test"], |
It should show an error that no files were found though. |
Hey @sheremet-va, yes you are right, it works as expected after I added Thanks for pointing that out... Also, But it seems that this still have some issues. Should I open a new issue for that specifically? As far as I'm concerned, the rest of this works as expected so you can close as resolved. |
You can open an issue there |
Yes, I assumed. I reported a bug there too. Just a friendly note for others, Okay, feel free to close this as resolved. Thanks for your time and help! |
Hey @sheremet-va, just a friendly reminder, this has been fixed in the latest version |
Describe the bug
Hi, first of all thanks for your work on this awesome project.
I would like to use Vitest for type checking.
I came across this example in the Vitest documentation, but it doesn't seem to work as it should.
The test passes even though there is a type checking error.
Is it intentional behavior? I expected the test to fail and report an error.
Reproduction
package.json
tsconfig.json
vitest.config.ts
test/types/test-example.ts
console report
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: