Skip to content

Commit

Permalink
test: retry "Something went wrong" GraphQL error
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Jan 25, 2023
1 parent 659b0f4 commit 6c21892
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions test/retry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,63 @@ describe("Automatic Retries", function () {

expect(caught).toEqual(testStatuses.length);
});

it('Should retry "Something went wrong" GraphQL error', async function () {
const octokit = new TestOctokit();

const result = await octokit.graphql({
query: `query {
viewer {
login
}
}`,
request: {
responses: [
{
status: 200,
headers: {},
data: {
errors: [
{
message:
// the `0000:0000:0000000:0000000:00000000` part is variable, it's the request ID provided by GitHub
"Something went wrong while executing your query. Please include `0000:0000:0000000:0000000:00000000` when reporting this issue.",
},
],
},
},
{
status: 200,
headers: {},
data: {
data: {
viewer: {
login: "gr2m",
},
},
},
},
],
retries: 1,
},
});

expect(result).toStrictEqual({
viewer: {
login: "gr2m",
},
});
expect(octokit.__requestLog).toStrictEqual([
"START POST /graphql",
"END POST /graphql",
"START POST /graphql",
"END POST /graphql",
]);

expect(
octokit.__requestTimings[1] - octokit.__requestTimings[0]
).toBeLessThan(20);
});
});

describe("errorRequest", function () {
Expand Down

0 comments on commit 6c21892

Please sign in to comment.