Emmanuel Rodríguez
Ninja Code
Mario Alexander Vargas Celis
Jairo Campos Ruiz
Emmanuel Rodríguez
Javier Fuentes Mora
ProfesorIsilreiberth José Pérez Rodríguez
¡Rock n' Roll! 🤟
📚 Cypress GraphQL
const query = `{ findUser(username:"hello") { id } }`; cy.request({ url: 'URL', body: { query }, failOnStatusCode: false }).then((response: any) => { cy.log(response); });
GraphQL funciona sobre el protocolo REST!
describe('Probando graphql',()=>{ it('debe de hacer una consulta con graphql', ()=>{ const gqlQuery = `query pokemons($limit: Int, $offset: Int) { pokemons(limit: $limit, offset: $offset) { count next previous status message results { url name image } } }`; const gqlVariables ={ limit:20, offset: 0 } cy.request({ method: "POST", url: 'https://graphql-pokeapi.graphcdn.app/', body:{ query: gqlQuery, variables: gqlVariables, }, }).then((response) =>{ //cy.log(response) expect(response.body.data.pokemons.results[0].name).to.equal("bulbasaur"); }) }); }); ```describe('Probando graphql',()=>{ it('debe de hacer una consulta con graphql', ()=>{ const gqlQuery = `query pokemons($limit: Int, $offset: Int) { pokemons(limit: $limit, offset: $offset) { count next previous status message results { url name image } } }`; const gqlVariables ={ limit:20, offset: 0 } cy.request({ method: "POST", url: 'https://graphql-pokeapi.graphcdn.app/', body:{ query: gqlQuery, variables: gqlVariables, }, }).then((response) =>{ //cy.log(response) expect(response.body.data.pokemons.results\[0].name).to.equal("bulbasaur"); }) });});
Alguien sabe si se puede testar una API que funcione con sockets con cypress?
O de lo contrario sabéis de algún framework o librería que lo permita?
Hola 👋
Como tal, librería esta Mock-Socket.
Y tal cual, se debe generar stubs, te anexo un stackoverflow.
Debería de poderse :)
Dejo la Api: https://graphql-pokeapi.graphcdn.app/