Skip to content
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

fix(cli): handle run mode correctly (fix #719) #717

Closed
wants to merge 4 commits into from

Conversation

DerYeger
Copy link
Member

@DerYeger DerYeger commented Feb 9, 2022

Closes #719

@netlify
Copy link

netlify bot commented Feb 9, 2022

✔️ Deploy Preview for vitest-dev ready!

🔨 Explore the source changes: 8544bf5

🔍 Inspect the deploy log: https://app.netlify.com/sites/vitest-dev/deploys/62042046fe2e9f000803c839

😎 Browse the preview: https://deploy-preview-717--vitest-dev.netlify.app

@DerYeger DerYeger changed the title fix(cli): add missing default values fix(cli): handle run mode correctly Feb 9, 2022
@DerYeger DerYeger changed the title fix(cli): handle run mode correctly fix(cli): handle run mode correctly (fix #719) Feb 9, 2022
@DerYeger DerYeger requested a review from antfu February 9, 2022 15:35
@DerYeger DerYeger added the bug label Feb 9, 2022
@@ -49,6 +49,7 @@ export const configDefaults: UserConfig = Object.freeze({
isolate: true,
watchIgnore: [/\/node_modules\//, /\/dist\//],
update: false,
run: !!process.env.CI,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix should be make watch default to false and handles it in CLI, /cc @sheremet-va

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fixed

@DerYeger DerYeger requested a review from antfu February 9, 2022 17:36

cli
.command('[...filters]')
.action(dev)
.action(run)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep the original naming? I found them a bit confusing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we don't really need the dev function anymore I now inlined the option overrides of vitest run.

@@ -56,7 +56,7 @@ export async function VitestPlugin(options: UserConfig = {}, ctx = new Vitest())
options,
)
options.api = resolveApiConfig(options)
options.watch = options.watch && !options.run
options.watch = !options.run
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should keep the original logic.

There are some logic under dev get removed in #702, we need to bring them back

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic of the dev function that got removed in #702 isn't needed anymore.
It was just acting as a default value, which is now included in configDefaults.

Copy link
Member

@patak-dev patak-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix looks good after the discussion. It would be good to avoid the redundant booleans { run: true, watch: false }, maybe a mode could be explored? A mode: 'watch' | 'run', like we have in vite with 'dev' | 'build'.

@DerYeger
Copy link
Member Author

DerYeger commented Feb 9, 2022

The fix looks good after the discussion. It would be good to avoid the redundant booleans { run: true, watch: false }, maybe a mode could be explored? A mode: 'watch' | 'run', like we have in vite with 'dev' | 'build'.

Absolutely, the separate run and watch are cumbersome.
We should use a mode type in our config and just parse the CLI args accordingly.
Since the current situation is quite a big issue I'd prefer to do it in a separate PR though.

@antfu antfu closed this in 837711d Feb 10, 2022
chaii3 pushed a commit to chaii3/vitest that referenced this pull request May 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vitest run is watching files and does not quit
3 participants