Skip to content

Commit aafc384

Browse files
committed
Sync testing for onResponse
1 parent 6217c8b commit aafc384

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

packages/core/tests/graphql-module.spec.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,7 +1746,7 @@ describe('GraphQLModule', () => {
17461746
moduleB,
17471747
],
17481748
});
1749-
const mockRequests: Array<MockResponse<{ hugeLoad: number[] }>> = [];
1749+
const mockRequests: Array<MockSession<{ hugeLoad: number[] }>> = [];
17501750
for (let i = 0; i < 1000; i++) {
17511751
mockRequests.push(createMockSession({ hugeLoad: new Array(1000).fill(1000) }));
17521752
}
@@ -1759,25 +1759,14 @@ describe('GraphQLModule', () => {
17591759
contextValue: mockRequest,
17601760
document: gql`{ aLoadLength bLoadLength abLoadLength baLoadLength }`,
17611761
});
1762-
mockRequest.res.once('finish', () => {
1763-
setTimeout(() => {
1764-
// tslint:disable-next-line: no-console
1765-
console.log('resolved');
1766-
// tslint:disable-next-line: no-console
1767-
console.time('GC');
1768-
(global.gc as any)(true);
1769-
// tslint:disable-next-line: no-console
1770-
console.timeEnd('GC');
1771-
resolve();
1772-
}, 1000);
1773-
});
17741762
mockRequest.res.emit('finish');
17751763
expect(data.aLoadLength).toBe(1000);
17761764
expect(data.bLoadLength).toBe(1000);
17771765
expect(data.abLoadLength).toBe(1000);
17781766
expect(data.baLoadLength).toBe(1000);
17791767
// tslint:disable-next-line: no-console
17801768
console.log(counter);
1769+
resolve();
17811770
})).then(() => {
17821771
done();
17831772
}).catch(done.fail);

0 commit comments

Comments
 (0)