#Jest Spyon gives error for type never?
10 messages · Page 1 of 1 (latest)
What is management? And what is its getClients method?
management is a client management to client to auth0
management = module.get<ManagementClient>('Auth0Management');```
and the getClients method fetchs clients from auth0
async getClients(): Promise<Client[]> {
const clients = await this.management.getClients();
return clients;
}
Interesting. Jest seems to think that the getClients is not an async method
yeah I read setting the mock response array would fix it but didn't quite do the trick 😅
Any chance you can share a link to the code?
I can't share to the repo since it's a company repo but I can share the contents of the files
That might help
full service
import { Injectable } from '@nestjs/common';
import { Client, ManagementClient } from 'auth0';
import { InjectManagement } from '@twirelab/nestjs-auth0';
import { ConfigService } from '@nestjs/config';
import { UpdateClientDto } from './dto/update-client.dto';
import { Neo4jService } from '../neo4j/neo4j.service';
@Injectable()
export class ClientsService {
constructor(
private configService: ConfigService,
@InjectManagement() private readonly management: ManagementClient,
private readonly neo4jService: Neo4jService,
) {}
async getClients(): Promise<Client[]> {
const clients = await this.management.getClients();
return clients;
}
async getClientsByFields(fields: string[]): Promise<Client[]> {
return await this.management.getClients({ fields });
}
async updateClient(
clientId: string,
updateClientDto: UpdateClientDto,
): Promise<Client> {
return await this.management.updateClient(
{ client_id: clientId },
updateClientDto,
);
}
}
This is probably a moment of ts-jest not fully realizing that getClients s either void (uses a callback) or returns a Promise. I bet you could // @ts-ignore it and it would be fine