MCPcopy Create free account
hub / github.com/deepnote/vscode-deepnote / initializeCommonWebApi

Function initializeCommonWebApi

src/test/common.web.ts:31–77  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29}
30
31export function initializeCommonWebApi() {
32 initializeCommonApi({
33 async createTemporaryFile(options: {
34 contents?: string;
35 extension: string;
36 }): Promise<{ file: Uri } & IDisposable> {
37 const folder = workspace.workspaceFolders![0].uri;
38 const tmpDir = Uri.joinPath(folder, 'temp', 'testFiles');
39 try {
40 await workspace.fs.createDirectory(tmpDir);
41 } catch {
42 // ignore if it exists..
43 }
44 const extension = options.extension || '.py';
45 const file = Uri.joinPath(tmpDir, `${generateUuid()}${extension}`);
46 const contents = options.contents || '';
47
48 await workspace.fs.writeFile(file, new TextEncoder().encode(contents));
49 return {
50 file,
51 dispose: () => {
52 workspace.fs.delete(file).then(noop, noop);
53 }
54 };
55 },
56 async startJupyterServer(_options?: {
57 token?: string;
58 port?: number;
59 useCert?: boolean;
60 jupyterLab?: boolean;
61 password?: string;
62 }): Promise<{ url: string } & IDisposable> {
63 // DEBUG_JUPYTER_SERVER_URI is not a valid setting, but updated when we launch the tests via vscode debugger.
64 const url = workspace.getConfiguration('deepnote').get('DEBUG_JUPYTER_SERVER_URI', JUPYTER_SERVER_URI);
65 console.log(`ServerURI for remote test: ${url}`);
66 // Server URI should have been embedded in the constants file
67 const uri = Uri.parse(url);
68 // Use this URI to set our jupyter server URI
69 await commands.executeCommand('deepnote.selectjupyteruri', uri);
70 return { url: url, dispose: noop };
71 },
72 async initialize() {
73 return initialize();
74 },
75 captureScreenShot
76 });
77}

Callers 1

index.web.test.tsFile · 0.90

Calls 1

initializeCommonApiFunction · 0.90

Tested by

no test coverage detected