Skip to content

Commit

Permalink
Test if error masking fn is called once
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan committed Mar 11, 2024
1 parent 8dfdf08 commit 1a07d35
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/graphql-yoga/__tests__/subscriptions.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GraphQLError } from 'graphql';
import { createSchema, createYoga, Plugin } from '../src/index.js';
import { createSchema, createYoga, maskError, Plugin } from '../src/index.js';
import { eventStream } from './utilities.js';

describe('Subscription', () => {
Expand Down Expand Up @@ -552,7 +552,12 @@ describe('subscription plugin hooks', () => {
},
};

const yoga = createYoga({ schema, plugins: [plugin] });
const maskErrorFn = jest.fn(maskError);
const yoga = createYoga({
schema,
plugins: [plugin],
maskedErrors: { maskError: maskErrorFn },
});

const response = await yoga.fetch('http://yoga/graphql', {
method: 'POST',
Expand Down Expand Up @@ -585,6 +590,7 @@ describe('subscription plugin hooks', () => {
expect(onNextCallCounter).toEqual(1);
expect(didInvokeOnEnd).toBe(true);
expect(didInvokeOnSubscribeError).toBe(true);
expect(maskErrorFn).toBeCalledTimes(1);
});
});

Expand Down

0 comments on commit 1a07d35

Please sign in to comment.