Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reproduce failure case in integration test #153

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 64 additions & 11 deletions final/server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion final/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"license": "ISC",
"dependencies": {
"apollo-datasource": "^0.1.3",
"apollo-datasource-rest": "^0.1.5",
"apollo-server": "^2.15.0",
"apollo-server-testing": "^2.15.0",
"aws-sdk": "^2.585.0",
Expand All @@ -27,6 +26,7 @@
},
"devDependencies": {
"apollo": "^2.1.8",
"apollo-datasource-rest": "0.9.3",
"apollo-link": "^1.2.3",
"apollo-link-http": "^1.5.5",
"jest": "^25.0.0",
Expand Down
31 changes: 31 additions & 0 deletions final/server/src/__tests__/__snapshots__/e2e.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,37 @@ Object {
}
`;

exports[`Server - e2e gets a single launch 2`] = `
Object {
"data": Object {
"launch": null,
},
"errors": Array [
Object {
"extensions": Object {
"code": "Not Found",
"response": Object {
"body": "Not Found",
"status": 404,
"statusText": "Not Found",
"url": "https://api.spacexdata.com/v2/launch?flight_number=30",
},
},
"locations": Array [
Object {
"column": 3,
"line": 2,
},
],
"message": "NOT_FOUND",
"path": Array [
"launch",
],
},
],
}
`;

exports[`Server - e2e gets list of launches 1`] = `
Object {
"data": Object {
Expand Down
17 changes: 17 additions & 0 deletions final/server/src/__tests__/__snapshots__/integration.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,20 @@ Object {
},
}
`;

exports[`Queries returns error for single launch 1`] = `
Object {
"data": Object {
"launch": null,
},
"errors": Array [
[GraphQLError: Unexpected error value: "Not Found"],
],
"extensions": undefined,
"http": Object {
"headers": Headers {
Symbol(map): Object {},
},
},
}
`;
19 changes: 9 additions & 10 deletions final/server/src/__tests__/__utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { HttpLink } = require('apollo-link-http');
const fetch = require('node-fetch');
const { execute, toPromise } = require('apollo-link');
const { HttpLink } = require("apollo-link-http");
const fetch = require("node-fetch");
const { execute, toPromise } = require("apollo-link");

module.exports.toPromise = toPromise;

Expand All @@ -12,8 +12,8 @@ const {
ApolloServer,
LaunchAPI,
UserAPI,
store,
} = require('../');
store
} = require("../");

/**
* Integration testing utils
Expand All @@ -26,7 +26,7 @@ const constructTestServer = ({ context = defaultContext } = {}) => {
typeDefs,
resolvers,
dataSources: () => ({ userAPI, launchAPI }),
context,
context
});

return { server, userAPI, launchAPI };
Expand All @@ -48,16 +48,15 @@ const startTestServer = async server => {

const link = new HttpLink({
uri: `http://localhost:${httpServer.port}`,
fetch,
fetch
});

const executeOperation = ({ query, variables = {} }) =>
execute(link, { query, variables });
const executeOperation = ({ query, variables = {} }) => execute(link, { query, variables });

return {
link,
stop: () => httpServer.server.close(),
graphql: executeOperation,
graphql: executeOperation
};
};

Expand Down
Loading