apollographql / apollographql/fullstack-tutorial
Integration Tests Not Properly Mocked
- Ngôn ngữ chính
- TypeScript
- Star
- 1.2k
- Fork
- 808
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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?
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Bắt đầu bằng cách chạy các bài kiểm thử tích hợp khi mạng bị vô hiệu hóa và kiểm tra ví dụ gán launchAPI.get, sau đó lần theo phương thức RESTDataSource xử lý việc tra cứu lần phóng. issue không nêu tên tệp hoặc lệnh kiểm thử nào; công việc được xem là hoàn tất khi các bài kiểm thử tích hợp chạy thành công ngoại tuyến mà không yêu cầu api.spacexdata.com và vẫn trả về dữ liệu tên lửa như mong đợi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- graphql, node.js, typescript
- Lĩnh vực
- api, backend, testing
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 35/100