在开玩笑中更改资产文件的路径

发布于 2025-02-12 17:22:00 字数 988 浏览 0 评论 0原文

因此,我想使用开玩笑进行E2E测试。我正在使用NX MonorePo架构,并且我的所有资产都在图书馆文件夹中,还有Nestjs Microservices的后端。我在库中有所有用于微服务的原始文件,当我想将它们加载到微服务中时,我会这样这样做:

protoPath: join(__dirname, 'assets-shared/job.proto'),

在我的workspace.json中,我在构建中,我会更改资产共享

"targets": {
    "build": {
      "options": {
        "assets": [
          {
            "input": "libs/backend/shared/src/lib/assets",
            "glob": "**/*",
            "output": "assets-shared"
          }
        ]
      },

:很好,但是当我运行测试以及当它要导入并为其提供值时,它不会更改它,并且我有此错误,该错误正在使用其文件夹,而不是库文件夹,

ENOENT: no such file or directory, open '/home/dev/Project/apps/backend/api/src/modules/product/assets-shared/job.proto'

我尝试了Modulenamemapper来给出手动的Libs文件夹,但无济于事。

 moduleNameMapper: {
  '^.+\\.(proto)$': 
  '<rootDir>/libs/backend/shared/src/lib/assets/$1',
  // '^assets-shared(.*)': '/libs/backend/shared/src/lib/assets/$1',
},

这两个工作中的非

So I want to run an e2e test using jest. I'm using nx monorepo architecture, and I have all my assets in a library folder and also nestjs microservices for my backend. I have all my proto files for my microservices in the library, and when I want to load them in my microservices, I do it like this :

protoPath: join(__dirname, 'assets-shared/job.proto'),

and in my workspace.json in my build i change the assets-shared like this:

"targets": {
    "build": {
      "options": {
        "assets": [
          {
            "input": "libs/backend/shared/src/lib/assets",
            "glob": "**/*",
            "output": "assets-shared"
          }
        ]
      },

all is good, but when I run the test and when it wants to import and give value to it, it doesn't change it, and I have this error which is trying in its folder and not the library folder

ENOENT: no such file or directory, open '/home/dev/Project/apps/backend/api/src/modules/product/assets-shared/job.proto'

I tried the moduleNameMapper to give the libs folder to it manually but no avail.

 moduleNameMapper: {
  '^.+\\.(proto)

non of these two worked

: '<rootDir>/libs/backend/shared/src/lib/assets/$1', // '^assets-shared(.*)': '/libs/backend/shared/src/lib/assets/$1', },

non of these two worked

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尴尬癌患者 2025-02-19 17:22:00

您是否考虑过将库发布到私人NPM存储库或 artifactory 例如 @my-company/

您正在尝试的方法可能在本地使用的方法,但是对于CI/CD管道,它将是最好在NPM或文物中使用版本的伪像

Have you considered publishing the libraries to a private npm repository or something like artifactory e.g. @my-company/assets

The approach you are trying may work locally, but for a ci/cd pipeline it would be much better to have a versioned artifact in npm or artifactory

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文