I'm trying to test modules on *.spec.ts, but i cannot.
written methods after expect always occur TS2239 error(Property ~ does not exist on type 'Assertion')
however, if i tag the @ts-ignore above the line, it successfully compile and test my code.
Thought it was a NestJS bug, but my other NestJS projects run tests well.
The only difference between the malfunctioned project and my other NestJS projects is using a static module to carry the Vue SPA files.
What should I have to check to solve this problem?
import { Test, TestingModule } from '@nestjs/testing';
import { AppController } from './app.controller';
import { AppService } from './app.service';
describe('AppController', () => {
let appController: AppController;
beforeEach(async () => {
const app: TestingModule = await Test.createTestingModule({
controllers: [AppController],
providers: [AppService],
}).compile();
appController = app.get<AppController>(AppController);
});
describe('root', () => {
it('should return "Hello World!"', () => {
// Error here: TS2339: Property 'toBe' does not exist on type 'Assertion'
// @ts-ignore can solve this problem, but it is not the correct answer i believe.
expect(appController.getHello()).toBe('Hello World!');
});
});
});
Tried to compare difference between the project that works and not.