Al aplicar test usando la version 16.x de graphql los test fallan, recomiendo usar la versión 15.8.0 o una versión similar, cuando aplique los test con la versión 16.x me aparecio: Expected undefined to be a GraphQL schema.
No estoy seguro pero creo que es por easygraphql-tester ya que usa la versión 15 y lleva más de 10 meses sin actualizarse
tengo un error que no de me deja avanzar amigo en esta parte del test:
export const createMockContext = (): MockResolverContext => {
return {
orm: mockDeep<PrismaClient>(),
user: undefined
};
};
El error es el siguiente:
Type of property 'OR' circularly references itself in mapped type '{ [K in keyof { AND?: Enumerable<UserScalarWhereWithAggregatesInput>; OR?: Enumerable<UserScalarWhereWithAggregatesInput>; ... 7 more ...; updatedAt?: string | ... 1 more ... | DateTimeWithAggregatesFilter; }]: Or<...> extends 1 ? { ...; }[K] extends infer TK ? GetHavingFields<...> : never : {} extends FieldPaths<.....'.
Tengo el mismo problema, no sé cómo lo solucionó el profesor.
Hay un issue relacionado con este problema.
Una alternativa para hacer los Test es con Cypress. ya existe un curso en platzi.
const apiGraphQL =`${Cypress.env('apiUrl')}/graphql`;describe('Avocados Queries and Mutations',function(){context('/graphql',function(){it('Gets a list of users',function(){ cy.request('POST',`${apiGraphQL}`,{query:`query {
users {
id
username
}
}`,}).then((response)=>{expect(response.status).to.eq(200);expect(response.body.data.users[0].id).to.eq(1);});});it('Gets a list of Avocados',function(){ cy.request('POST',`${apiGraphQL}`,{query:`query {
avos {
id
name
}
}`,}).then((response)=>{expect(response.status).to.eq(200);expect(response.body.data.avos[0].name).to.eq('Fuerte Avocado');});});it('Gets a Avocado by ID',function(){ cy.request('POST',`${apiGraphQL}`,{query:`query Query($avoId: ID!) {
avo(id: $avoId) {
id
name
}
}`,variables:{avoId:5,},}).then((response)=>{expect(response.status).to.eq(200);expect(response.body.data.avo.name).to.eq('Hass Avocado');});});});});