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

watchExclude option doesn't work for code in node_modules in some cases #4785

Closed
6 tasks done
Jinjiang opened this issue Dec 20, 2023 · 1 comment · Fixed by #4945 or #4976
Closed
6 tasks done

watchExclude option doesn't work for code in node_modules in some cases #4785

Jinjiang opened this issue Dec 20, 2023 · 1 comment · Fixed by #4945 or #4976
Assignees
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@Jinjiang
Copy link

Describe the bug

From what I tried so far, the watchExclude for code in node_modules option doesn't work when:

  • the environment is node.
  • the environment is jsdom and
    • the first time you edit the main file of a node module, or
    • every time you edit a non-main file of a node module

More discussion info: #4772 (reply in thread)

Reproduction

https://github.com/Jinjiang/reproductions/tree/vitest-watch-node_modules-20231220

pnpm install

# you can switch environment between 'node' (default value) and 'jsdom'
pnpm test

# in 'node' environment:
#
# modify any code in node_modules
# - the test is not re-run

# in 'jsdom' environment:
#
# modify code in node_modules/foo-cjs/index.js or node_modules/foo-esm/index.js
# - when you first time modify it, the test is not re-run
# - when you further modify it, the test is re-run
#
# modify code in node_modules/foo-cjs/foo.js or node_modules/foo-esm/foo.js
# - the test is not re-run

The expected behavior is that the test is always re-run when any code in node_modules/foo-cjs and node_modules/foo-esm is modified whatever the environment is.

System Info

System:
    OS: macOS 14.3
    CPU: (8) arm64 Apple M1
    Memory: 88.61 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.1.0 - ~/.asdf/installs/nodejs/20.1.0/bin/node
    Yarn: 1.22.19 - ~/.asdf/shims/yarn
    npm: 9.6.4 - ~/.asdf/plugins/nodejs/shims/npm
    pnpm: 8.12.0 - ~/Library/pnpm/pnpm
  Browsers:
    Safari: 17.3
  npmPackages:
    vite: ^5.0.10 => 5.0.10 
    vitest: ^1.0.4 => 1.0.4

Used Package Manager

pnpm

Validations

@sheremet-va
Copy link
Member

sheremet-va commented Jan 16, 2024

In https://github.com/Jinjiang/reproductions/tree/vitest-watch-node_modules-20231220 when using jsdom environment, Vitest reruns changed node_modules file without any changes.

Other issues from README (tests are not rerun with node environment) are not reproducible.

@sheremet-va sheremet-va reopened this Jan 16, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jan 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
2 participants