Skip to content

Nx caching inputs missing for all projects using setupFiles or globalSetup in vitest.config.ts #1029

@BioPhoton

Description

@BioPhoton

Update:
We have to re-evaluate the issue after #1142 is merged


What happened?

If I change something in a testing lib the packages using them over setupFiles or globalSetup in vitest.config.ts have a false cache hit.

The problem:
Project models als all other projects miss the dependencies to testing files referenced in vitest.config.ts.

What would you expect to happen?

If I change something in a testing lib the packages using them over setupFiles or globalSetup in vitest.config.ts do not have a cache hit.

Possible Solutions:

  • add implicitDependencies to all relevant testing targets - quick but not fine-grained also the biggest downside is our build and any other target in the project would be affected. ⚠️
  • add the used files from vitest.config.ts as target inputs/namedInputs - fine-grained but only maintainable over custom plugin that adds the inputs. But as the used filse in setupFiles or globalSetup change it has to be dynamically detected.
  • create a config project handling the setupFiles and is directly depending on testing-setup (best)

What steps did you take?

  1. ✅ Test the project modles in packages/models and verify cache hit
  # [existing outputs match the cache, left as is] <= ✅ this is correct. It should have a cache hit
   nx run models:unit-test
  1. ✅ Apply any code change in the project testing-setup in folder testing/setup and save the change to your filesystem
  2. ❌ Test the project modles in packages/models and verify NO cache hit - nx unit-test models
  # [existing outputs match the cache, left as is] <= ❌ this is not correct. It should not have a cache hit
   nx run models:unit-test

Code PushUp package version

No response

What operation system are you on?

MacOS

Node version

24

Relevant log output

Related information

Metadata

Metadata

Assignees

No one assigned

    Labels

    🌊 NxNx related issues🐛 bugsomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions