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

Watch mode behaviour can't be override from CLI #710

Closed
6 tasks done
ShivamJoker opened this issue Feb 9, 2022 · 11 comments
Closed
6 tasks done

Watch mode behaviour can't be override from CLI #710

ShivamJoker opened this issue Feb 9, 2022 · 11 comments

Comments

@ShivamJoker
Copy link
Contributor

Describe the bug

Watch mode behaviour can't be override by passing flags from CLI

Reproduction

Create a basic test app from docs

Disable watch mode in config

/// <reference types="vitest" />
import { defineConfig } from "vite";

export default defineConfig({
  test: {
    watch: false,
  },
});

Try running watch mode from CLI

npx vitest watch

or

npx vitest --watch

Screenshots 👇

image

System Info

System:
    OS: macOS 12.1
    CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
    Memory: 275.97 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 17.4.0 - /usr/local/bin/node
    Yarn: 1.22.17 - /usr/local/bin/yarn
    npm: 8.4.1 - /usr/local/bin/npm
  Browsers:
    Chrome: 98.0.4758.80
    Safari: 15.2
  npmPackages:
    vitest: ^0.2.7 => 0.2.7

Used Package Manager

yarn

Validations

@ShivamJoker ShivamJoker changed the title Watch mode get's overwritten by config file Watch mode behaviour can't be override from CLI Feb 9, 2022
@DerYeger
Copy link
Member

DerYeger commented Feb 9, 2022

I had a look at the source code and the config file is supposed to override the CLI args.

options = deepMerge(options, viteConfig.test as any || {})

Do you need so set watch to false in the config?
You could just disable watch mode by using vitest run when required.

@ShivamJoker
Copy link
Contributor Author

ShivamJoker commented Feb 9, 2022

Ohh the CLI should override it. And by default watch is enabled #696 (I sent PR for this)

@DerYeger
Copy link
Member

DerYeger commented Feb 9, 2022

Ohh the CLI should override it by default watch is enabled #696 (I sent PR for this)

I'm not sure what you mean.
The default is !process.env.CI && !argv.run.
This is overridden by the CLI, which in return is overridden by the config.

@ShivamJoker
Copy link
Contributor Author

ShivamJoker commented Feb 9, 2022

@DerYeger thats what I am trying to say by default the watch is enabled, and to disable it I set the watch to false in config file.
But I want to enable watch from the CLI flag, How do I do it?

@DerYeger
Copy link
Member

DerYeger commented Feb 9, 2022

You can't.
Remove the watch: false and use vitest run instead of vitest.
If you want watch mode enabled, use vitest or even vitest run --watch.

@ShivamJoker
Copy link
Contributor Author

okay it works that way.

But I believe CLI should override the default config no matter what 🙅

@Demivan
Copy link
Member

Demivan commented Feb 9, 2022

I agree with @ShivamJoker here. CLI args should override config.
I was using threads: true in config and --no-threads CLI arg was working just fine.

@DerYeger
Copy link
Member

DerYeger commented Feb 9, 2022

Will be closed by #702

@DerYeger DerYeger closed this as completed Feb 9, 2022
@ShivamJoker
Copy link
Contributor Author

@DerYeger so now it's fixed?

@DerYeger
Copy link
Member

DerYeger commented Feb 9, 2022 via email

@sheremet-va
Copy link
Member

There is now an issue: vitest run enables watch mode (#713 (comment))

chaii3 pushed a commit to chaii3/vitest that referenced this issue May 13, 2022
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
@github-actions github-actions bot locked and limited conversation to collaborators Jun 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants