【发布时间】:2021-08-30 17:46:48
【问题描述】:
我昨天升级到 Nestjs v8,我怀疑我的问题与此有关。
之前,我可以像这样创建一个测试模块:
beforeAll(async () => {
const moduleRef = await Test.createTestingModule({
...appModuleMetaData,
providers: [...appModuleMetaData.providers, TestingService],
}).compile();
app = moduleRef.createNestApplication();
await app.init();
testingService = app.get('TestingService');
});
这似乎不再可能,因为 Nest 无法获取 TestingService。目前,我看到了错误:
Nest 找不到 TestingService 元素(此提供程序不 存在于当前上下文中)
我很想以某种方式解决这个问题。
【问题讨论】:
-
几乎是文档在此处显示的 docs.nestjs.com/techniques/configuration#using-in-the-maints(在此处搜索
app.get之后)
标签: nestjs