I am using Jest to test my songs.controller.spec.ts
file, but VSCode cannot detect the module @nestjs/testing
and the describe
method on the songs.controller.spec.ts
file. The file content is the following (just a default spec file generated by Nest).
import { Test, TestingModule } from '@nestjs/testing';
import { SongsController } from './songs.controller';
describe('SongsController', () => {
let controller: SongsController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [SongsController],
}).compile();
controller = module.get<SongsController>(SongsController);
});
it('should be defined', () => {
expect(controller).toBeDefined();
});
});
Weirdly, describe
works on mock-function.spec.js
file. It seems to work on JS file but not on TS file. Why?
I have no jest config by default at all. You can check my code structure and its configs here: https://github.com/richard-here/songs-be