property signin, sign up does not exist on type AuthService

82 Views Asked by At

auth.controller file

`import { Test, TestingModule } from '@nestjs/testing';
import { AuthController } from './auth.controller';

describe('AuthController', () => {
  let controller: AuthController;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      controllers: [AuthController],
    }).compile();

    controller = module.get<AuthController>(AuthController);
  });

  it('should be defined', () => {
    expect(controller).toBeDefined();
  });
});`

auth.service file

`import { Injectable } from '@nestjs/common';

@Injectable({})
export class AuthService {
signin()
{
    return { msg: 'i am signin' };
}

signup()
{
    return  { msg: 'i am signup' };
}

}`

i am beginner level and getting this type of error even if remove all the code to simple return message my vcode gives same error what can be the issue

1

There are 1 best solutions below

0
Jay McDoniel On

I'm surprised you're not getting a Dependency Injection error related to a missing AuthService dependency. You need to provide a custom provider for the AuthService to inject into the AuthController for the purpose of testing.

This repository has a lot of testing examples to take a look at