Skip to content

Commit 0909033

Browse files
authored
test(attach): fix "emits disconnect" timeout #414
Problem: This test may time out, because the `proc.on('close')` event is never triggered. FAIL src/attach/attach.test.ts (5.62 s) ● Nvim API › emits "disconnect" after quit thrown: "Exceeded timeout of 5000 ms for a test while waiting for `done()` to be called. | }); | > | it('emits "disconnect" after quit', done => { | ^ | const disconnectMock = jest.fn(); | nvim.on('disconnect', disconnectMock); | nvim.quit(); at it (src/attach/attach.test.ts:138:3) at Object.describe (src/attach/attach.test.ts:6:1) Solution: Listen for 'exit' instead of 'close'. This may indicate that Nvim or node-client is not properly closing all of its streams, but that is unrelated to this particular test.
1 parent e28b0c6 commit 0909033

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/neovim/src/attach/attach.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,12 @@ describe('Nvim API', () => {
157157
it('emits "disconnect" after quit', done => {
158158
const disconnectMock = jest.fn();
159159
nvim.on('disconnect', disconnectMock);
160+
160161
nvim.quit();
161162

162-
proc.on('close', () => {
163-
expect(disconnectMock.mock.calls.length).toBe(1);
163+
// TODO: 'close' event sometimes does not emit. #414
164+
proc.on('exit', () => {
165+
expect(disconnectMock).toHaveBeenCalledTimes(1);
164166
done();
165167
});
166168

0 commit comments

Comments
 (0)