Skip to content

Commit aee97b7

Browse files
committed
Fix tests (add missing shims missing in jsdom) and warnings
1 parent 24c7bdf commit aee97b7

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

packages/jupyterlab-lsp/jest.config.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const upstream = func('jupyterlab-lsp', __dirname);
44
const reuseFromUpstream = [
55
'moduleFileExtensions',
66
'moduleNameMapper',
7-
'setupFiles',
87
'setupFilesAfterEnv',
98
'testPathIgnorePatterns'
109
];
@@ -28,7 +27,11 @@ let local = {
2827
},
2928
transformIgnorePatterns: [`/node_modules/(?!${esModules}).+`],
3029
testLocationInResults: true,
31-
reporters: [...upstream['reporters'], 'jest-github-actions-reporter']
30+
reporters: [...upstream['reporters'], 'jest-github-actions-reporter'],
31+
setupFiles: [
32+
...upstream['setupFiles'],
33+
'@krassowski/jupyterlab-lsp/lib/jest-shim.js'
34+
]
3235
};
3336

3437
for (const option of reuseFromUpstream) {

packages/jupyterlab-lsp/src/connection.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ export class LSPConnection extends LspWsConnection {
452452
method,
453453
message: params
454454
});
455-
this.connection.sendNotification(method, params);
455+
this.connection.sendNotification(method, params).catch(console.error);
456456
});
457457
}
458458

@@ -618,10 +618,9 @@ export class LSPConnection extends LspWsConnection {
618618
} as lsp.VersionedTextDocumentIdentifier,
619619
contentChanges: changeEvents
620620
};
621-
this.connection.sendNotification(
622-
'textDocument/didChange',
623-
textDocumentChange
624-
);
621+
this.connection
622+
.sendNotification('textDocument/didChange', textDocumentChange)
623+
.catch(console.error);
625624
documentInfo.version++;
626625
}
627626

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// TODO: remove after upgrading to JupyterLab 4.0
2+
const util = require('util');
3+
(global as any).TextDecoder = util.TextDecoder;
4+
(global as any).TextEncoder = util.TextEncoder;

packages/lsp-ws-connection/src/ws-connection.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ export class LspWsConnection
186186
version: documentInfo.version
187187
} as protocol.TextDocumentItem
188188
};
189-
this.connection.sendNotification(
189+
void this.connection.sendNotification(
190190
'textDocument/didOpen',
191191
textDocumentMessage
192192
);
@@ -209,7 +209,7 @@ export class LspWsConnection
209209
} as protocol.VersionedTextDocumentIdentifier,
210210
contentChanges: [{ text: documentInfo.text }]
211211
};
212-
this.connection.sendNotification(
212+
void this.connection.sendNotification(
213213
'textDocument/didChange',
214214
textDocumentChange
215215
);
@@ -228,7 +228,7 @@ export class LspWsConnection
228228
} as protocol.VersionedTextDocumentIdentifier,
229229
text: documentInfo.text
230230
};
231-
this.connection.sendNotification(
231+
void this.connection.sendNotification(
232232
'textDocument/didSave',
233233
textDocumentChange
234234
);
@@ -241,7 +241,7 @@ export class LspWsConnection
241241
return;
242242
}
243243

244-
this.connection.sendNotification(
244+
void this.connection.sendNotification(
245245
'workspace/didChangeConfiguration',
246246
settings
247247
);
@@ -606,8 +606,8 @@ export class LspWsConnection
606606
protected onServerInitialized(params: protocol.InitializeResult) {
607607
this.isInitialized = true;
608608
this.serverCapabilities = params.capabilities;
609-
this.connection.sendNotification('initialized', {});
610-
this.connection.sendNotification('workspace/didChangeConfiguration', {
609+
void this.connection.sendNotification('initialized', {});
610+
void this.connection.sendNotification('workspace/didChangeConfiguration', {
611611
settings: {}
612612
});
613613
this.emit('serverInitialized', this.serverCapabilities);

0 commit comments

Comments
 (0)