Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[Bug] vitest missing in package.json of testtools

未关闭 适合新手
#2,659 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
1/5
预计耗时
1 小时以内
新手友好度
68/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
冷清
领域
testing-qa

调研方向

从 packages/testtools/package.json 开始 — vitest 在 packages/testtools/src/vitest-ext.ts 第 2 行被导入(并通过 src/schema.ts 中的 loadSchema 到达),但并未声明。检查同级包如何声明仅测试用的工具,在 dependencies 和隔离的入口点之间做出决定,然后运行 yarn install 和一个基于 Jest 的消费者导入 @zenstackhq/testtools。完成意味着 Jest 项目不再出现 Cannot find module 'vitest';注意报告者提供了一个从未落地的 PR,因此在开始前与维护者确认。

由索引模型根据 Issue 内容生成。

描述

Description and expected behavior
The package vitest is imported in the file https://github.com/zenstackhq/zenstack/blob/ce50d3ba4804c8f5095f19fdf74d405dc4b182b3/packages/testtools/src/vitest-ext.ts#L2 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.

主要语言
TypeScript
星标
2.9k
派生
157
平均合并
11 小时 42 分钟
30 天内合并 PR
20

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

zenstackhq/zenstack 的其他 Issue

查看 zenstackhq/zenstack 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。