Comments (14)
Same goes for checking types using --typecheck
option.
from vitest.
I don't understand you issue. Vitest reruns only affected tests on file change, not every test.
from vitest.
I don't understand you issue. Vitest reruns only affected tests on file change, not every test.
Vitest shows that there's only 1 test file on a rerun, which isn't true. If I want to test just that file, I'll specify it when running the command.
from vitest.
From what I can see in the reproduction, this issue is not about running affected tests, but running affected tests and tests that failed before. If I remember correctly, Vitest was running all failing tests plus affected tests before at some point, so this looks like a regression.
What Vitest will not do is run all tests when one test is changed because it doesn't make any sense - the status of all your other tests will not change because test files are isolated.
from vitest.
From what I can see in the reproduction, this issue is not about running affected tests, but running affected tests and tests that failed before. If I remember correctly, Vitest was running all failing tests plus affected tests before at some point, so this looks like a regression.
Yes, thanks, this is kinda what I was trying to convey. Was there a purpose to rerunning non-affected failed tests?
What Vitest will not do is run all tests when one test is changed because it doesn't make any sense - the status of all your other tests will not change because test files are isolated.
Makes sense — the results of the other tests can be reused regardless of their outcome.
from vitest.
Maybe related to this PR?
It looks like this PR is introducing "file change -> rerun file change and failed ones"
from vitest.
Is there a flag or is vitest supposed to to always rerun all tests when any test file changes? That's what I've been searching for...
from vitest.
is vitest supposed to to always rerun all tests when any test file changes?
@waynebloss Vitest is not supposed to do this as explained in #4997 (comment)
This is expected to provide a better experience for most of the users, but if this behavior is not preferable for some reason, then it would help if you can share more details about your use case.
As an exception, for example config files change, Vitest should re-run everything and we have forceRerunTriggers
for that purpose https://vitest.dev/config/#forcereruntriggers. Maybe this is what you're looking for?
from vitest.
@hi-ogawa Thank you. I am a new user giving vitest
a chance after enjoying the use of the excellent vite
.
Mainly, I just want to see all the nice check marks (and totals) all of the time. So I am having to use nodemon to work around this currently.
The problem IMO is that the default console output is not stable after a rerun, so you have to scroll back up to history to see results from previous runs. It's also not stable depending on if there is more than one test file or not. (With a single test file, you get sub-check marks for each test in that file but with multiple test files you get no sub-check marks.)
I know this is not the place for this issue and I haven't completely explored all the reporting options yet so perhaps I'll look at those and also give the UI a try.
from vitest.
So, I solved my own related stability issue by just using --reporter=verbose
. I guess what I really want is a verbose-caching
reporter so I'll be continuing the search...
from vitest.
@hi-ogawa Here is my final report in response to your query:
- I have tried the UI and it is indeed a stable UI. I don't like that you can't see a whole outline of all test files and their tests at once and just scroll up and down to see details. However, more importantly, I really don't want to open yet another window to work with a given project, especially one that also takes up the terminal pane used to start the UI window. As such, I will continue using nodemon + vitest via
vitest run --reporter=verbose
for now. - With regards to using
forceRerunTriggers
, I suppose that I could try to set it to be the same paths as theinclude
files but when I tried that in myvitest.workspace.ts
in my repo root I found outforceRerunTriggers
is one of the configs that can't be in the workspace file. Even if it worked, it would be smelly IMO. See [0]- Also, what if a file that I change modifies some database e.g. a Redis store or some other external thing that isn't a file? I love the simplicity of just re-running all tests, especially at the beginning of a project when the tests all run very quickly.
- At later stages of a project, I might turn that flag off when I want to focus on a single test file at a time.
So I think a simple flag to allow always rerunning would be useful.
from vitest.
@waynebloss Thanks for providing the details. It looks like you're feeling some UI/UX issues of builtin reporters, so if you want to expand on that, please feel free to open new issue or use new discussion if it's just a quick question https://github.com/vitest-dev/vitest/discussions
As for forceRerunTriggers
, I think your "smelly" one indeed doesn't work since this config has to be defined for "root" config. Also I think having forceRerunTriggers
same as include
is not enough since I suppose you want to rerun everything when you change any source files (not necessary test files).
In your case, probably forceRerunTriggers: ["**/*"]
is what you want. I made an example project here. Could you take a look?
https://stackblitz.com/edit/vitest-dev-vitest-xysf8w?file=vitest.config.ts
from vitest.
@hi-ogawa That works very well, thanks again!
I was also able to avoid creating a separate vite.config.ts
file in each of my packages by using the extended workspace definition shown in my previous comment, but without the error shown. Originally to that end, I had tried to put the vite-tsconfig-paths
plugins definition code into the root vite.config.ts
but that did not work so knowing where a config can go remains somewhat confusing to me.
However, I can get rid of nodemon now and we'll see how that goes. Thank you very much for your help.
from vitest.
As a team, we decided that it would be nice to show previously failed test files in the terminal, but we won't show the errors in those files to not clutter the output. The tests themselves will not be running, unless the change will affect the file.
from vitest.
Related Issues (20)
- Browser mode is flaky HOT 1
- OOM when running vitest in docker HOT 3
- Wrong diff for objectContaining
- inner suite `{ sequential: true }` doesn't override outer suite `{ concurrent: true }`
- 执行 vitest 时报错 ast.body is not iterable HOT 1
- Remove version labels for Vitest 2 documentation
- Text reporter still creates an empty coverage folder HOT 3
- using setupFiles from parent dir causes 'Failed to load url' HOT 2
- Check for listen port collision for browser tests HOT 6
- Add `aroundEach` Hook Similar to RSpec `around` HOT 9
- Segmentation fault - Test fails when using Vitest, but passes when using Jest HOT 2
- Mixing browser and non-browser projects in vitest workspace causes error HOT 2
- testNamePattern doesn't parse RegEx'es in the CLI, or documentation is unclear HOT 2
- get error "Could not parse CSS stylesheet" when CSS file contains nested rules HOT 2
- Issue with `vitest --run --changed` when used with lint-staged on Windows HOT 2
- Default reporter emits `prepare` longer than `Duration` when prepare takes longer than 1s HOT 3
- test.each does not print -0 and -NaN correctly
- `vi.fn()` performs an extra _await_ leading to mismatching behaviour when compared with normal function HOT 5
- restoreAllMocks doesn't restore mocks HOT 4
- API for timer mocks that are safely isolated between tests HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vitest.