Skip to content

[Bug] vitest missing in package.json of testtools #2659

Closed

Description

@jasonmacdonald-lgtm

Description and expected behavior
The package vitest is imported in the file

import { expect } from 'vitest';
but is not listed as a dependency of the package.json.

This causes an error for projects that don't use Vite, but would like to use @zenstackhq/testtools in their Jest tests. As an example, we would like to use the loadSchema function in our tests to load schemas, but this currently throws the error Cannot find module 'vitest' due to the missing package dependency. This likely is only an issue for projects using Jest instead of Vite. Many older projects will likely be in this position.

While this can be resolved by the project including it as a dependency, this seems like something that should really be handled by the package. It really doesn't make sense for a Jest based project to include vitest. :)

Unfortunately, this only one of many issues we are running into when trying to use Zenstack v3 with a project that uses CommonJS (older project) and Jest.

Environment (please complete the following information):

  • ZenStack version:3.1.0
  • Database type: Postgresql
  • Node.js/Bun version: v24.14.0
  • Package manager: [yarn
  • test suite: Jest

Additional context

I will submit a PR shortly for this.

Activity

  1. jasonmacdonald commented on May 8, 2026

    @jasonmacdonald
    Contributor

    Sorry, this was my ticket but I posted under the wrong account :)

    Looking further into it to make a PR, I'm not sure how exactly you want to handle this, as most of the package deps use catalog, but vitest isn't in the catalog.

  2. ymc9 commented on May 13, 2026

    @ymc9
    Member

    Thanks for filing this @jasonmacdonald . The "testtools" package was mainly for internal consumption and currently tightly coupled with vitest. V3's tests are now run against ESM build. I remember having tons of issues trying to get Jest to work with ESM, not sure if recent builds have made it easier ...

    PR is always much appreciated!

  3. thelastbackspace commented on Nov 5, 2026

    @thelastbackspace
    Contributor

    I'd like to send a small PR for this: declare vitest as a peer dependency of testtools, with a regression test that checks its runtime imports are all declared.

  4. ymc9 commented on Nov 5, 2026

    @ymc9
    Member

    Of course. A PR is much appreciated!

  5. thelastbackspace commented on Nov 5, 2026

    @thelastbackspace
    Contributor

    Thanks! It's up as #2909.

  6. ymc9 commented on Nov 13, 2026

    @ymc9
    Member

    Fixed by #2909, released in v3.10.2: vitest is now a peer dependency of @zenstackhq/testtools.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions