vscode在子文件夹中启动开玩笑测试

发布于 2025-02-12 12:00:40 字数 643 浏览 0 评论 0原文

我正在一个具有jest.config.jspackage.json文件的monorepo中,在该monorepo中代表独立项目的 package.json

items/thing/
items/other/
items/something/

焦点中的测试文件,然后我可以使用此配置项目在items/thing/文件夹中运行该测试文件。

"name": "Jest (this file)",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}/items/thing",
"runtimeArgs": [
    "--inspect-brk",
    "${workspaceFolder}/node_modules/.bin/jest",
    "${relativeFile}"
],

但是,要在项目/其他/文件夹中执行相同的操作,我需要将cwd属性更改为该值。

有没有办法将cwd与具有配置/软件包文件的最接近的父母“联系” ? (还是解决这个问题的另一种方法?)

I am working in a monorepo that has jest.config.js and package.json files in subfolders that represent independent projects in this monorepo, example:

items/thing/
items/other/
items/something/

In VSCode, if I have a test file in focus, I can then use this config item to run that test file in the items/thing/ folder.

"name": "Jest (this file)",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}/items/thing",
"runtimeArgs": [
    "--inspect-brk",
    "${workspaceFolder}/node_modules/.bin/jest",
    "${relativeFile}"
],

However, to do the same in the items/other/ folder I need to change the cwd property to that value.

Is there a way to "tie" the cwd to the closest parent that has the config/package files so I don't have to adjust the launch.json settings each time? (Or another way to solve this?)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文