小编Ver*_*uze的帖子

请确保索引 [0] 处的参数 ContactRepository 在 RootTestModule 上下文中可用

我正在尝试通过 Nest 测试一个课程。在这个类中(参见下图),对该类进行编码的人通过 typeorm 创建一个存储库。

在此输入图像描述

当我尝试测试“createContact”函数时,出现以下错误:“Nest 无法解析 ContactService 的依赖项(?)。请确保索引 [0] 处的参数 ContactRepository 在 AuthModule 上下文中可用”。

这是我的测试课:

在此输入图像描述

您知道如何使测试考虑到这一点,从而不再出现错误吗?

typescript jestjs nestjs

20
推荐指数
1
解决办法
2万
查看次数

玩笑:ReferenceError:未定义描述

我尝试按照本教程为我的项目设置 jest:https : //dev.to/nedsoft/testing-nodejs-express-api-with-jest-and-supertest-1km6

但是,当我尝试运行基本测试时,出现以下错误:

 FAIL  tests/sample.test.js
  ? Test suite failed to run

    ReferenceError: describe is not defined

    > 1 | describe('Sample Test', () => {
        | ^
      2 |     it('should test that true === true', () => {
      3 |         expect(true).toBe(true)
      4 |     })

      at Object.<anonymous> (tests/sample.test.js:1:1)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        1.521 s
Ran all test suites.
(node:15452) ExperimentalWarning: The fs.promises API is experimental
npm ERR! Test failed.  See …
Run Code Online (Sandbox Code Playgroud)

javascript jestjs

1
推荐指数
1
解决办法
3872
查看次数

标签 统计

jestjs ×2

javascript ×1

nestjs ×1

typescript ×1