Testing - Can't resolve all parameters for (ClassName)

前端 未结 4 1202
清歌不尽
清歌不尽 2020-11-30 11:04

Context

I created an ApiService class to be able to handle our custom API queries, while using our own serializer + other features.

ApiSer

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-30 11:58

    Using Jest?

    In case anyone gets here AND you're using Jest to test your Angular app (hopefully we're a growing minority), you will run into this error if you are not emitting decorators. You'll need to update your tsconfig.spec.json file so it looks like:

    {
      "extends": "../../tsconfig.json",
      "compilerOptions": {
        "emitDecoratorMetadata": true,
        "outDir": "../../out-tsc/spec",
        "types": [
          "jest",
          "node"
        ]
      },
      "files": [
      ],
      "include": [
        "**/*.spec.ts",
        "**/*.d.ts"
      ]
    }
    

提交回复
热议问题