Skip to content

Commit 18b08e1

Browse files
committed
fix tests, and add normal error
1 parent 2f60bef commit 18b08e1

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

packages/graphql-yoga/__tests__/error-masking.spec.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,12 +872,16 @@ describe('error masking', () => {
872872
typeDefs: /* GraphQL */ `
873873
type Query {
874874
a: String!
875+
b: String!
875876
}
876877
`,
877878
resolvers: {
878879
Query: {
879880
a: () => {
880-
throw createGraphQLError('Test Error', { coordinate: 'Query.a' });
881+
throw createGraphQLError('Test Error');
882+
},
883+
b: () => {
884+
throw new Error('Test Error');
881885
},
882886
},
883887
},
@@ -904,5 +908,26 @@ describe('error masking', () => {
904908
},
905909
],
906910
});
911+
912+
const response2 = await yoga.fetch('http://yoga/graphql', {
913+
method: 'POST',
914+
headers: {
915+
accept: 'application/graphql-response+json',
916+
'content-type': 'application/json',
917+
},
918+
body: JSON.stringify({ query: '{ b }' }),
919+
});
920+
921+
const body2 = await response2.json();
922+
expect(response2.status).toEqual(200);
923+
924+
expect(body2).toMatchObject({
925+
errors: [
926+
{
927+
message: 'Unexpected error.',
928+
coordinate: 'Query.b',
929+
},
930+
],
931+
});
907932
});
908933
});

0 commit comments

Comments
 (0)