akveo / akveo/ngx-admin-bundle-support

Failing unit test on NestJS Starter Kit app.controller.spec.ts

Open
#72 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
56
Forks
30
PR merge metrics
No merged PRs in 30d

Description

`npm test` results in a failed test and this error message:

> Nest can't resolve dependencies of the AppController (AppService, ?). Please make sure that the argument at index [1] is available in the _RootTestModule context.

a mock provider for the `SeedService` should also be injected, since app controller also has a dependency on it. Here is the corrected code which generates a passing test:

```
describe('AppController', () => {
let appController: AppController;
const mockSeedService = {
checkAndSeed: () => {},
};

beforeEach(async () => {
const app: TestingModule = await Test.createTestingModule({
controllers: [AppController],
providers: [
AppService,
{
provide: 'SeedService',
useValue: mockSeedService,
},
],
}).compile();

appController = app.get(AppController);
});
...
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.