Skip to content

Commit a6f75e6

Browse files
committed
polish: fix test
I introduced use of expect.fail() in graphql#3760 mistakenly believing that expect.fail() will always cause the test to fail. Actually, expect.fail() just throws an error, and that error is wrapped is wrapped by GraphQL and then filtered, so the lines are reached. Fortunately, it's not a problem that the line is reached, as long as it is filtered correctly. The number of calls to next() may be more than 1 (in our case it is 2) depending on the # of ticks that it takes for the deferred fragment to resolve. So the test as written is intending to be overly strict, but is broken and so functions as desires. This commit makes no change to the test semantics, but changes the comment, the coverage ignore statement, and removes the confusing use of expect.fail, so that the test semantics are more clearly apparent.
1 parent 7a609a2 commit a6f75e6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/execution/__tests__/stream-test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { assert, expect } from 'chai';
1+
import { assert } from 'chai';
22
import { describe, it } from 'mocha';
33

44
import { expectJSON } from '../../__testUtils__/expectJSON.js';
@@ -1422,9 +1422,8 @@ describe('Execute: stream directive', () => {
14221422
[Symbol.asyncIterator]: () => ({
14231423
next: () => {
14241424
if (requested) {
1425-
/* c8 ignore next 3 */
1426-
// Not reached, iterator should end immediately.
1427-
expect.fail('Not reached');
1425+
// Ignores further errors when filtered.
1426+
return Promise.reject(new Error('Oops'));
14281427
}
14291428
requested = true;
14301429
const friend = friends[0];
@@ -1438,6 +1437,7 @@ describe('Execute: stream directive', () => {
14381437
},
14391438
return: () => {
14401439
returned = true;
1440+
// Ignores errors from return.
14411441
return Promise.reject(new Error('Oops'));
14421442
},
14431443
}),

0 commit comments

Comments
 (0)