apollographql / apollographql/fullstack-tutorial
Integration Tests Not Properly Mocked
- Lenguaje dominante
- TypeScript
- Estrellas
- 1.2k
- Forks
- 808
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
I followed the integration tests example pattern in my own app.
```
// mock the datasources' underlying fetch methods, whether that's a REST
// lookup in the RESTDataSource or the store query in the Sequelize datasource
launchAPI.get = jest.fn(() => [mockLaunchResponse]);
```
However I noticed it was still making api calls to the rest endpoint. I then cloned this repo turned off my wifi and ran the integration tests and sure enough I got an error.
```
errors": Array [
+ Object {
+ "extensions": Object {
+ "code": "INTERNAL_SERVER_ERROR",
+ "exception": Object {
+ "code": "ENOTFOUND",
+ "errno": "ENOTFOUND",
+ "message": "request to https://api.spacexdata.com/v2/launches?flight_number=30 failed, reason: getaddrinfo ENOTFOUND api.spacexdata.com api.spacexdata.com:443",
+ "type": "system",
+ },
},
- "rocket": Object {
- "type": "FT",
- },
+ "locations": Array [
+ Object {
+ "column": 3,
+ "line": 2,
+ },
+ ],
+ "message": "request to https://api.spacexdata.com/v2/launches?flight_number=30 failed, reason: getaddrinfo ENOTFOUND api.spacexdata.com api.spacexdata.com:443",
+ "path": Array [
+ "launch",
+ ],
```
This tells me that `launchAPI.get` is not being properly mocked. Which I think would make sense as there is no `launchAPI.get` however there is a `launchAPI.prototype.get` however that doesn't seem to work when I change the tests to that.
Any ideas?
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
Empieza ejecutando las pruebas de integración con la red deshabilitada e inspecciona el ejemplo que asigna launchAPI.get; después, sigue el método de RESTDataSource que gestiona la búsqueda del lanzamiento. El issue no menciona archivos ni comandos de prueba; debe considerarse terminado cuando las pruebas de integración pasen sin conexión, sin solicitar api.spacexdata.com, y sigan devolviendo los datos esperados del cohete.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- graphql, node.js, typescript
- Área
- api, backend, testing
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 35/100