-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Tests stop failing after including regular tests in typecheck #5019
Comments
Running into the same issue. It's not clear from the docs whether this behavior is intentional or a bug. My impression was that the same If this is working as intended, then it means the regular |
This is the expected solution. Typechecking tests have a separate The problem is that it's not that easy to aggregate test results that were collected during running and type-checking for several reasons:
You do not need to run |
We hit this issue today, as we didn't realise that we couldn't have both types of tests in the same test file. We'd prefer to do this, as it saves us writing some tests twice. Are you able to provide a small example of how |
Same issue here. I got confused by the behaviour. I expect if there's a type error then the tests should fail. Otherwise, devs might be pushing misleading test code to the repository without a way to prevent it reliably ( CI wouldn't catch this because no error has risen ). What is more important is that enabling typechecks should not suppress existing assertions, otherwise, someone could ship bugs to production. Here's how I encountered it ( fortunately it was local tiny pet project ).I was working on a function whose first version accepted a single argument. The function code and corresponding test are written in Typescript.I needed to introduce another argument for the function. I thought I missed some config for the vitest, so I enabled |
I've been trying Here is an example: export default defineConfig({
test: {
include: ['src/**/*.test.ts?(x)'],
poolMatchGlobs: [
['src/**/*.test.ts?(x)', 'threads'],
['src/**/*.ts?(x)', 'typescript'],
],
}
}) upd. the only way I found is to add vite-plugin-checker but it would not fail the tests |
same issue here. My expectation was also to be able to run type tests and functionality tests in the same file. For now just using tsc manually. ( |
Describe the bug
After enabling typecheck and including regular test files (using
include
typecheck config option), when running the tests, only typecheck is performed, with the tests themselves passing regardless of any value assertions.Setting
only
typecheck option tofalse
doesn't seem to do anything.Upd1: Current solution is to separate the regular tests and type tests to different files.
Upd2: Separating regular tests and type tests seems to result in an issue when saving the regular test file. Instead of rerunning the just-saved regular test file, instead the type test file is being rerun. Created an issue: #5020
Reproduction
Repo: https://github.com/murolem/vitest-issue-when-typecheck-is-used-tests-are-not-failing
Run
npm run test
.Enable/disable typecheck in the config to see the issue.
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: