@jupyterlab/testing 4.0.0-alpha.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/babel-config.d.ts +8 -0
- package/lib/babel-config.js +20 -0
- package/lib/babel-config.js.map +1 -0
- package/lib/common.d.ts +89 -0
- package/lib/common.js +216 -0
- package/lib/common.js.map +1 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +26 -0
- package/lib/index.js.map +1 -0
- package/lib/jest-config.d.ts +1 -0
- package/lib/jest-config.js +59 -0
- package/lib/jest-config.js.map +1 -0
- package/lib/jest-file-mock.d.ts +0 -0
- package/lib/jest-file-mock.js +6 -0
- package/lib/jest-file-mock.js.map +1 -0
- package/lib/jest-raw-loader.d.ts +0 -0
- package/lib/jest-raw-loader.js +14 -0
- package/lib/jest-raw-loader.js.map +1 -0
- package/lib/jest-shim.d.ts +2 -0
- package/lib/jest-shim.js +100 -0
- package/lib/jest-shim.js.map +1 -0
- package/lib/start_jupyter_server.d.ts +62 -0
- package/lib/start_jupyter_server.js +324 -0
- package/lib/start_jupyter_server.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) Jupyter Development Team.
|
|
4
|
+
* Distributed under the terms of the Modified BSD License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const babelConfig = {
|
|
8
|
+
presets: [
|
|
9
|
+
[
|
|
10
|
+
'@babel/preset-env',
|
|
11
|
+
{
|
|
12
|
+
targets: {
|
|
13
|
+
node: 'current'
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
]
|
|
18
|
+
};
|
|
19
|
+
exports.default = babelConfig;
|
|
20
|
+
//# sourceMappingURL=babel-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"babel-config.js","sourceRoot":"","sources":["../src/babel-config.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAEH,MAAM,WAAW,GAAG;IAClB,OAAO,EAAE;QACP;YACE,mBAAmB;YACnB;gBACE,OAAO,EAAE;oBACP,IAAI,EAAE,SAAS;iBAChB;aACF;SACF;KACF;CACF,CAAC;AAEF,kBAAe,WAAW,CAAC"}
|
package/lib/common.d.ts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { ISignal } from '@lumino/signaling';
|
|
2
|
+
export { sleep } from '@jupyterlab/coreutils/lib/testutils';
|
|
3
|
+
/**
|
|
4
|
+
* Test a single emission from a signal.
|
|
5
|
+
*
|
|
6
|
+
* @param signal - The signal we are listening to.
|
|
7
|
+
* @param find - An optional function to determine which emission to test,
|
|
8
|
+
* defaulting to the first emission.
|
|
9
|
+
* @param test - An optional function which contains the tests for the emission, and should throw an error if the tests fail.
|
|
10
|
+
* @param value - An optional value that the promise resolves to if the test is
|
|
11
|
+
* successful.
|
|
12
|
+
*
|
|
13
|
+
* @returns a promise that rejects if the function throws an error (e.g., if an
|
|
14
|
+
* expect test doesn't pass), and resolves otherwise.
|
|
15
|
+
*
|
|
16
|
+
* #### Notes
|
|
17
|
+
* The first emission for which the find function returns true will be tested in
|
|
18
|
+
* the test function. If the find function is not given, the first signal
|
|
19
|
+
* emission will be tested.
|
|
20
|
+
*
|
|
21
|
+
* You can test to see if any signal comes which matches a criteria by just
|
|
22
|
+
* giving a find function. You can test the very first signal by just giving a
|
|
23
|
+
* test function. And you can test the first signal matching the find criteria
|
|
24
|
+
* by giving both.
|
|
25
|
+
*
|
|
26
|
+
* The reason this function is asynchronous is so that the thing causing the
|
|
27
|
+
* signal emission (such as a websocket message) can be asynchronous.
|
|
28
|
+
*/
|
|
29
|
+
export declare function testEmission<T, U, V>(signal: ISignal<T, U>, options?: {
|
|
30
|
+
find?: (a: T, b: U) => boolean;
|
|
31
|
+
test?: (a: T, b: U) => void;
|
|
32
|
+
value?: V;
|
|
33
|
+
}): Promise<V | undefined>;
|
|
34
|
+
/**
|
|
35
|
+
* Expect a failure on a promise with the given message.
|
|
36
|
+
*/
|
|
37
|
+
export declare function expectFailure(promise: Promise<any>, message?: string): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Do something in the future ensuring total ordering with respect to promises.
|
|
40
|
+
*/
|
|
41
|
+
export declare function doLater(cb: () => void): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Convert a signal into an array of promises.
|
|
44
|
+
*
|
|
45
|
+
* @param signal - The signal we are listening to.
|
|
46
|
+
* @param numberValues - The number of values to store.
|
|
47
|
+
*
|
|
48
|
+
* @returns a Promise that resolves with an array of `(sender, args)` pairs.
|
|
49
|
+
*/
|
|
50
|
+
export declare function signalToPromises<T, U>(signal: ISignal<T, U>, numberValues: number): Promise<[T, U]>[];
|
|
51
|
+
/**
|
|
52
|
+
* Convert a signal into a promise for the first emitted value.
|
|
53
|
+
*
|
|
54
|
+
* @param signal - The signal we are listening to.
|
|
55
|
+
*
|
|
56
|
+
* @returns a Promise that resolves with a `(sender, args)` pair.
|
|
57
|
+
*/
|
|
58
|
+
export declare function signalToPromise<T, U>(signal: ISignal<T, U>): Promise<[T, U]>;
|
|
59
|
+
/**
|
|
60
|
+
* Test to see if a promise is fulfilled.
|
|
61
|
+
*
|
|
62
|
+
* @param delay - optional delay in milliseconds before checking
|
|
63
|
+
* @returns true if the promise is fulfilled (either resolved or rejected), and
|
|
64
|
+
* false if the promise is still pending.
|
|
65
|
+
*/
|
|
66
|
+
export declare function isFulfilled<T>(p: PromiseLike<T>, delay?: number): Promise<boolean>;
|
|
67
|
+
/**
|
|
68
|
+
* Convert a requestAnimationFrame into a Promise.
|
|
69
|
+
*/
|
|
70
|
+
export declare function framePromise(): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Wait for a dialog to be attached to an element.
|
|
73
|
+
*/
|
|
74
|
+
export declare function waitForDialog(host?: HTMLElement, timeout?: number): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Accept a dialog after it is attached by accepting the default button.
|
|
77
|
+
*/
|
|
78
|
+
export declare function acceptDialog(host?: HTMLElement, timeout?: number): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Click on the warning button in a dialog after it is attached
|
|
81
|
+
*/
|
|
82
|
+
export declare function dangerDialog(host?: HTMLElement, timeout?: number): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Dismiss a dialog after it is attached.
|
|
85
|
+
*
|
|
86
|
+
* #### Notes
|
|
87
|
+
* This promise will always resolve successfully.
|
|
88
|
+
*/
|
|
89
|
+
export declare function dismissDialog(host?: HTMLElement, timeout?: number): Promise<void>;
|
package/lib/common.js
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) Jupyter Development Team.
|
|
4
|
+
* Distributed under the terms of the Modified BSD License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.dismissDialog = exports.dangerDialog = exports.acceptDialog = exports.waitForDialog = exports.framePromise = exports.isFulfilled = exports.signalToPromise = exports.signalToPromises = exports.doLater = exports.expectFailure = exports.testEmission = exports.sleep = void 0;
|
|
8
|
+
const simulate_event_1 = require("simulate-event");
|
|
9
|
+
const coreutils_1 = require("@lumino/coreutils");
|
|
10
|
+
const signaling_1 = require("@lumino/signaling");
|
|
11
|
+
const testutils_1 = require("@jupyterlab/coreutils/lib/testutils");
|
|
12
|
+
var testutils_2 = require("@jupyterlab/coreutils/lib/testutils");
|
|
13
|
+
Object.defineProperty(exports, "sleep", { enumerable: true, get: function () { return testutils_2.sleep; } });
|
|
14
|
+
/**
|
|
15
|
+
* Test a single emission from a signal.
|
|
16
|
+
*
|
|
17
|
+
* @param signal - The signal we are listening to.
|
|
18
|
+
* @param find - An optional function to determine which emission to test,
|
|
19
|
+
* defaulting to the first emission.
|
|
20
|
+
* @param test - An optional function which contains the tests for the emission, and should throw an error if the tests fail.
|
|
21
|
+
* @param value - An optional value that the promise resolves to if the test is
|
|
22
|
+
* successful.
|
|
23
|
+
*
|
|
24
|
+
* @returns a promise that rejects if the function throws an error (e.g., if an
|
|
25
|
+
* expect test doesn't pass), and resolves otherwise.
|
|
26
|
+
*
|
|
27
|
+
* #### Notes
|
|
28
|
+
* The first emission for which the find function returns true will be tested in
|
|
29
|
+
* the test function. If the find function is not given, the first signal
|
|
30
|
+
* emission will be tested.
|
|
31
|
+
*
|
|
32
|
+
* You can test to see if any signal comes which matches a criteria by just
|
|
33
|
+
* giving a find function. You can test the very first signal by just giving a
|
|
34
|
+
* test function. And you can test the first signal matching the find criteria
|
|
35
|
+
* by giving both.
|
|
36
|
+
*
|
|
37
|
+
* The reason this function is asynchronous is so that the thing causing the
|
|
38
|
+
* signal emission (such as a websocket message) can be asynchronous.
|
|
39
|
+
*/
|
|
40
|
+
async function testEmission(signal, options = {}) {
|
|
41
|
+
const done = new coreutils_1.PromiseDelegate();
|
|
42
|
+
const object = {};
|
|
43
|
+
signal.connect((sender, args) => {
|
|
44
|
+
var _a, _b, _c;
|
|
45
|
+
if ((_b = (_a = options.find) === null || _a === void 0 ? void 0 : _a.call(options, sender, args)) !== null && _b !== void 0 ? _b : true) {
|
|
46
|
+
try {
|
|
47
|
+
signaling_1.Signal.disconnectReceiver(object);
|
|
48
|
+
if (options.test) {
|
|
49
|
+
options.test(sender, args);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
done.reject(e);
|
|
54
|
+
}
|
|
55
|
+
done.resolve((_c = options.value) !== null && _c !== void 0 ? _c : undefined);
|
|
56
|
+
}
|
|
57
|
+
}, object);
|
|
58
|
+
return done.promise;
|
|
59
|
+
}
|
|
60
|
+
exports.testEmission = testEmission;
|
|
61
|
+
/**
|
|
62
|
+
* Expect a failure on a promise with the given message.
|
|
63
|
+
*/
|
|
64
|
+
async function expectFailure(promise, message) {
|
|
65
|
+
let called = false;
|
|
66
|
+
try {
|
|
67
|
+
await promise;
|
|
68
|
+
called = true;
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
if (message && err.message.indexOf(message) === -1) {
|
|
72
|
+
throw Error(`Error "${message}" not in: "${err.message}"`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (called) {
|
|
76
|
+
throw Error(`Failure was not triggered, message was: ${message}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.expectFailure = expectFailure;
|
|
80
|
+
/**
|
|
81
|
+
* Do something in the future ensuring total ordering with respect to promises.
|
|
82
|
+
*/
|
|
83
|
+
async function doLater(cb) {
|
|
84
|
+
await Promise.resolve(void 0);
|
|
85
|
+
cb();
|
|
86
|
+
}
|
|
87
|
+
exports.doLater = doLater;
|
|
88
|
+
/**
|
|
89
|
+
* Convert a signal into an array of promises.
|
|
90
|
+
*
|
|
91
|
+
* @param signal - The signal we are listening to.
|
|
92
|
+
* @param numberValues - The number of values to store.
|
|
93
|
+
*
|
|
94
|
+
* @returns a Promise that resolves with an array of `(sender, args)` pairs.
|
|
95
|
+
*/
|
|
96
|
+
function signalToPromises(signal, numberValues) {
|
|
97
|
+
const values = new Array(numberValues);
|
|
98
|
+
const resolvers = new Array(numberValues);
|
|
99
|
+
for (let i = 0; i < numberValues; i++) {
|
|
100
|
+
values[i] = new Promise(resolve => {
|
|
101
|
+
resolvers[i] = resolve;
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
let current = 0;
|
|
105
|
+
function slot(sender, args) {
|
|
106
|
+
resolvers[current++]([sender, args]);
|
|
107
|
+
if (current === numberValues) {
|
|
108
|
+
cleanup();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
signal.connect(slot);
|
|
112
|
+
function cleanup() {
|
|
113
|
+
signal.disconnect(slot);
|
|
114
|
+
}
|
|
115
|
+
return values;
|
|
116
|
+
}
|
|
117
|
+
exports.signalToPromises = signalToPromises;
|
|
118
|
+
/**
|
|
119
|
+
* Convert a signal into a promise for the first emitted value.
|
|
120
|
+
*
|
|
121
|
+
* @param signal - The signal we are listening to.
|
|
122
|
+
*
|
|
123
|
+
* @returns a Promise that resolves with a `(sender, args)` pair.
|
|
124
|
+
*/
|
|
125
|
+
function signalToPromise(signal) {
|
|
126
|
+
return signalToPromises(signal, 1)[0];
|
|
127
|
+
}
|
|
128
|
+
exports.signalToPromise = signalToPromise;
|
|
129
|
+
/**
|
|
130
|
+
* Test to see if a promise is fulfilled.
|
|
131
|
+
*
|
|
132
|
+
* @param delay - optional delay in milliseconds before checking
|
|
133
|
+
* @returns true if the promise is fulfilled (either resolved or rejected), and
|
|
134
|
+
* false if the promise is still pending.
|
|
135
|
+
*/
|
|
136
|
+
async function isFulfilled(p, delay = 0) {
|
|
137
|
+
const x = Object.create(null);
|
|
138
|
+
let race;
|
|
139
|
+
if (delay > 0) {
|
|
140
|
+
race = (0, testutils_1.sleep)(delay, x);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
race = x;
|
|
144
|
+
}
|
|
145
|
+
const result = await Promise.race([p, race]).catch(() => false);
|
|
146
|
+
return result !== x;
|
|
147
|
+
}
|
|
148
|
+
exports.isFulfilled = isFulfilled;
|
|
149
|
+
/**
|
|
150
|
+
* Convert a requestAnimationFrame into a Promise.
|
|
151
|
+
*/
|
|
152
|
+
function framePromise() {
|
|
153
|
+
const done = new coreutils_1.PromiseDelegate();
|
|
154
|
+
requestAnimationFrame(() => {
|
|
155
|
+
done.resolve(void 0);
|
|
156
|
+
});
|
|
157
|
+
return done.promise;
|
|
158
|
+
}
|
|
159
|
+
exports.framePromise = framePromise;
|
|
160
|
+
/**
|
|
161
|
+
* Wait for a dialog to be attached to an element.
|
|
162
|
+
*/
|
|
163
|
+
async function waitForDialog(host = document.body, timeout = 250) {
|
|
164
|
+
const interval = 25;
|
|
165
|
+
const limit = Math.floor(timeout / interval);
|
|
166
|
+
for (let counter = 0; counter < limit; counter++) {
|
|
167
|
+
if (host.getElementsByClassName('jp-Dialog')[0]) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
await (0, testutils_1.sleep)(interval);
|
|
171
|
+
}
|
|
172
|
+
throw new Error('Dialog not found');
|
|
173
|
+
}
|
|
174
|
+
exports.waitForDialog = waitForDialog;
|
|
175
|
+
/**
|
|
176
|
+
* Accept a dialog after it is attached by accepting the default button.
|
|
177
|
+
*/
|
|
178
|
+
async function acceptDialog(host = document.body, timeout = 250) {
|
|
179
|
+
await waitForDialog(host, timeout);
|
|
180
|
+
const node = host.getElementsByClassName('jp-Dialog')[0];
|
|
181
|
+
if (node) {
|
|
182
|
+
(0, simulate_event_1.simulate)(node, 'keydown', { keyCode: 13 });
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
exports.acceptDialog = acceptDialog;
|
|
186
|
+
/**
|
|
187
|
+
* Click on the warning button in a dialog after it is attached
|
|
188
|
+
*/
|
|
189
|
+
async function dangerDialog(host = document.body, timeout = 250) {
|
|
190
|
+
await waitForDialog(host, timeout);
|
|
191
|
+
const node = host.getElementsByClassName('jp-mod-warn')[0];
|
|
192
|
+
if (node) {
|
|
193
|
+
(0, simulate_event_1.simulate)(node, 'click', { button: 1 });
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
exports.dangerDialog = dangerDialog;
|
|
197
|
+
/**
|
|
198
|
+
* Dismiss a dialog after it is attached.
|
|
199
|
+
*
|
|
200
|
+
* #### Notes
|
|
201
|
+
* This promise will always resolve successfully.
|
|
202
|
+
*/
|
|
203
|
+
async function dismissDialog(host = document.body, timeout = 250) {
|
|
204
|
+
try {
|
|
205
|
+
await waitForDialog(host, timeout);
|
|
206
|
+
}
|
|
207
|
+
catch (error) {
|
|
208
|
+
return; // Ignore calls to dismiss the dialog if there is no dialog.
|
|
209
|
+
}
|
|
210
|
+
const node = host.getElementsByClassName('jp-Dialog')[0];
|
|
211
|
+
if (node) {
|
|
212
|
+
(0, simulate_event_1.simulate)(node, 'keydown', { keyCode: 27 });
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
exports.dismissDialog = dismissDialog;
|
|
216
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,mDAA0C;AAE1C,iDAAoD;AAEpD,iDAAoD;AAEpD,mEAA4D;AAE5D,iEAA4D;AAAnD,kGAAA,KAAK,OAAA;AAEd;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACI,KAAK,UAAU,YAAY,CAChC,MAAqB,EACrB,UAII,EAAE;IAEN,MAAM,IAAI,GAAG,IAAI,2BAAe,EAAiB,CAAC;IAClD,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,MAAM,CAAC,OAAO,CAAC,CAAC,MAAS,EAAE,IAAO,EAAE,EAAE;;QACpC,IAAI,MAAA,MAAA,OAAO,CAAC,IAAI,wDAAG,MAAM,EAAE,IAAI,CAAC,mCAAI,IAAI,EAAE;YACxC,IAAI;gBACF,kBAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;gBAClC,IAAI,OAAO,CAAC,IAAI,EAAE;oBAChB,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;iBAC5B;aACF;YAAC,OAAO,CAAC,EAAE;gBACV,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;aAChB;YACD,IAAI,CAAC,OAAO,CAAC,MAAA,OAAO,CAAC,KAAK,mCAAI,SAAS,CAAC,CAAC;SAC1C;IACH,CAAC,EAAE,MAAM,CAAC,CAAC;IACX,OAAO,IAAI,CAAC,OAAO,CAAC;AACtB,CAAC;AAxBD,oCAwBC;AAED;;GAEG;AACI,KAAK,UAAU,aAAa,CACjC,OAAqB,EACrB,OAAgB;IAEhB,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,IAAI;QACF,MAAM,OAAO,CAA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;KACpC;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,4DAA4D;KACrE;IAED,MAAM,IAAI,GAAG,IAAI,CAAC,sBAAsB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IAEzD,IAAI,IAAI,EAAE;QACR,IAAA,yBAAQ,EAAC,IAAmB,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;KAC3D;AACH,CAAC;AAfD,sCAeC"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* @module testing
|
|
4
|
+
*/
|
|
5
|
+
export { testEmission, expectFailure, signalToPromises, signalToPromise, isFulfilled, framePromise, sleep, waitForDialog, acceptDialog, dangerDialog, dismissDialog } from './common';
|
|
6
|
+
export { JupyterServer } from './start_jupyter_server';
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* -----------------------------------------------------------------------------
|
|
3
|
+
| Copyright (c) Jupyter Development Team.
|
|
4
|
+
| Distributed under the terms of the Modified BSD License.
|
|
5
|
+
|----------------------------------------------------------------------------*/
|
|
6
|
+
/**
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
* @module testing
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.JupyterServer = exports.dismissDialog = exports.dangerDialog = exports.acceptDialog = exports.waitForDialog = exports.sleep = exports.framePromise = exports.isFulfilled = exports.signalToPromise = exports.signalToPromises = exports.expectFailure = exports.testEmission = void 0;
|
|
12
|
+
var common_1 = require("./common");
|
|
13
|
+
Object.defineProperty(exports, "testEmission", { enumerable: true, get: function () { return common_1.testEmission; } });
|
|
14
|
+
Object.defineProperty(exports, "expectFailure", { enumerable: true, get: function () { return common_1.expectFailure; } });
|
|
15
|
+
Object.defineProperty(exports, "signalToPromises", { enumerable: true, get: function () { return common_1.signalToPromises; } });
|
|
16
|
+
Object.defineProperty(exports, "signalToPromise", { enumerable: true, get: function () { return common_1.signalToPromise; } });
|
|
17
|
+
Object.defineProperty(exports, "isFulfilled", { enumerable: true, get: function () { return common_1.isFulfilled; } });
|
|
18
|
+
Object.defineProperty(exports, "framePromise", { enumerable: true, get: function () { return common_1.framePromise; } });
|
|
19
|
+
Object.defineProperty(exports, "sleep", { enumerable: true, get: function () { return common_1.sleep; } });
|
|
20
|
+
Object.defineProperty(exports, "waitForDialog", { enumerable: true, get: function () { return common_1.waitForDialog; } });
|
|
21
|
+
Object.defineProperty(exports, "acceptDialog", { enumerable: true, get: function () { return common_1.acceptDialog; } });
|
|
22
|
+
Object.defineProperty(exports, "dangerDialog", { enumerable: true, get: function () { return common_1.dangerDialog; } });
|
|
23
|
+
Object.defineProperty(exports, "dismissDialog", { enumerable: true, get: function () { return common_1.dismissDialog; } });
|
|
24
|
+
var start_jupyter_server_1 = require("./start_jupyter_server");
|
|
25
|
+
Object.defineProperty(exports, "JupyterServer", { enumerable: true, get: function () { return start_jupyter_server_1.JupyterServer; } });
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;+EAG+E;AAC/E;;;GAGG;;;AAEH,mCAYkB;AAXhB,sGAAA,YAAY,OAAA;AACZ,uGAAA,aAAa,OAAA;AACb,0GAAA,gBAAgB,OAAA;AAChB,yGAAA,eAAe,OAAA;AACf,qGAAA,WAAW,OAAA;AACX,sGAAA,YAAY,OAAA;AACZ,+FAAA,KAAK,OAAA;AACL,uGAAA,aAAa,OAAA;AACb,sGAAA,YAAY,OAAA;AACZ,sGAAA,YAAY,OAAA;AACZ,uGAAA,aAAa,OAAA;AAGf,+DAAuD;AAA9C,qHAAA,aAAa,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) Jupyter Development Team.
|
|
4
|
+
* Distributed under the terms of the Modified BSD License.
|
|
5
|
+
*/
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const esModules = [
|
|
12
|
+
'@codemirror',
|
|
13
|
+
'@jupyter/ydoc',
|
|
14
|
+
'lib0',
|
|
15
|
+
'nanoid',
|
|
16
|
+
'vscode-ws-jsonrpc',
|
|
17
|
+
'y-protocols',
|
|
18
|
+
'y-websocket',
|
|
19
|
+
'yjs'
|
|
20
|
+
].join('|');
|
|
21
|
+
module.exports = function (baseDir) {
|
|
22
|
+
return {
|
|
23
|
+
testEnvironment: 'jsdom',
|
|
24
|
+
moduleNameMapper: {
|
|
25
|
+
'\\.(css|less|sass|scss)$': 'identity-obj-proxy',
|
|
26
|
+
'\\.(gif|ttf|eot)$': '@jupyterlab/testing/lib/jest-file-mock.js'
|
|
27
|
+
},
|
|
28
|
+
transform: {
|
|
29
|
+
'\\.svg$': '@jupyterlab/testing/lib/jest-raw-loader.js',
|
|
30
|
+
// Extracted from https://github.com/kulshekhar/ts-jest/blob/v29.0.3/presets/index.js
|
|
31
|
+
'^.+\\.tsx?$': [
|
|
32
|
+
'ts-jest/legacy',
|
|
33
|
+
{
|
|
34
|
+
tsconfig: `./tsconfig.test.json`
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
'^.+\\.jsx?$': 'babel-jest'
|
|
38
|
+
},
|
|
39
|
+
testTimeout: 10000,
|
|
40
|
+
setupFiles: ['@jupyterlab/testing/lib/jest-shim.js'],
|
|
41
|
+
testPathIgnorePatterns: ['/lib/', '/node_modules/'],
|
|
42
|
+
moduleFileExtensions: [
|
|
43
|
+
'ts',
|
|
44
|
+
'tsx',
|
|
45
|
+
'js',
|
|
46
|
+
'jsx',
|
|
47
|
+
'json',
|
|
48
|
+
'node',
|
|
49
|
+
'mjs',
|
|
50
|
+
'cjs'
|
|
51
|
+
],
|
|
52
|
+
transformIgnorePatterns: [`/node_modules/(?!${esModules}).+`],
|
|
53
|
+
reporters: ['default', 'jest-junit', 'github-actions'],
|
|
54
|
+
coverageReporters: ['json', 'lcov', 'text', 'html'],
|
|
55
|
+
coverageDirectory: path_1.default.join(baseDir, 'coverage'),
|
|
56
|
+
testRegex: '/test/.*.spec.ts[x]?$'
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=jest-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jest-config.js","sourceRoot":"","sources":["../src/jest-config.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;AAEH,gDAAwB;AAExB,MAAM,SAAS,GAAG;IAChB,aAAa;IACb,eAAe;IACf,MAAM;IACN,QAAQ;IACR,mBAAmB;IACnB,aAAa;IACb,aAAa;IACb,KAAK;CACN,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEZ,MAAM,CAAC,OAAO,GAAG,UAAU,OAAe;IACxC,OAAO;QACL,eAAe,EAAE,OAAO;QACxB,gBAAgB,EAAE;YAChB,0BAA0B,EAAE,oBAAoB;YAChD,mBAAmB,EAAE,2CAA2C;SACjE;QACD,SAAS,EAAE;YACT,SAAS,EAAE,4CAA4C;YACvD,qFAAqF;YACrF,aAAa,EAAE;gBACb,gBAAgB;gBAChB;oBACE,QAAQ,EAAE,sBAAsB;iBACjC;aACF;YACD,aAAa,EAAE,YAAY;SAC5B;QACD,WAAW,EAAE,KAAK;QAClB,UAAU,EAAE,CAAC,sCAAsC,CAAC;QACpD,sBAAsB,EAAE,CAAC,OAAO,EAAE,gBAAgB,CAAC;QACnD,oBAAoB,EAAE;YACpB,IAAI;YACJ,KAAK;YACL,IAAI;YACJ,KAAK;YACL,MAAM;YACN,MAAM;YACN,KAAK;YACL,KAAK;SACN;QACD,uBAAuB,EAAE,CAAC,oBAAoB,SAAS,KAAK,CAAC;QAC7D,SAAS,EAAE,CAAC,SAAS,EAAE,YAAY,EAAE,gBAAgB,CAAC;QACtD,iBAAiB,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;QACnD,iBAAiB,EAAE,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC;QACjD,SAAS,EAAE,uBAAuB;KACnC,CAAC;AACJ,CAAC,CAAC"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jest-file-mock.js","sourceRoot":"","sources":["../src/jest-file-mock.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAC,OAAO,GAAG,gBAAgB,CAAC"}
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Jupyter Development Team.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
// jest-raw-loader compatibility with Jest version 28.
|
|
6
|
+
// See: https://github.com/keplersj/jest-raw-loader/pull/239
|
|
7
|
+
module.exports = {
|
|
8
|
+
process: (content) => {
|
|
9
|
+
return {
|
|
10
|
+
code: 'module.exports = ' + JSON.stringify(content)
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=jest-raw-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jest-raw-loader.js","sourceRoot":"","sources":["../src/jest-raw-loader.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,sDAAsD;AACtD,4DAA4D;AAC5D,MAAM,CAAC,OAAO,GAAG;IACf,OAAO,EAAE,CAAC,OAAe,EAAoB,EAAE;QAC7C,OAAO;YACL,IAAI,EAAE,mBAAmB,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;SACpD,CAAC;IACJ,CAAC;CACF,CAAC"}
|
package/lib/jest-shim.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Jupyter Development Team.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
// Shims originally adapted from https://github.com/nteract/nteract/blob/47f8b038ff129543e42c39395129efc433eb4e90/scripts/test-shim.js
|
|
6
|
+
/* global globalThis */
|
|
7
|
+
globalThis.DragEvent = class DragEvent {
|
|
8
|
+
};
|
|
9
|
+
if (typeof globalThis.TextDecoder === 'undefined' ||
|
|
10
|
+
typeof globalThis.TextEncoder === 'undefined') {
|
|
11
|
+
const util = require('util');
|
|
12
|
+
globalThis.TextDecoder = util.TextDecoder;
|
|
13
|
+
globalThis.TextEncoder = util.TextEncoder;
|
|
14
|
+
}
|
|
15
|
+
const fetchMod = (window.fetch = require('node-fetch'));
|
|
16
|
+
window.Request = fetchMod.Request;
|
|
17
|
+
window.Headers = fetchMod.Headers;
|
|
18
|
+
window.Response = fetchMod.Response;
|
|
19
|
+
globalThis.Image = window.Image;
|
|
20
|
+
globalThis.Range = function Range() {
|
|
21
|
+
/* no-op */
|
|
22
|
+
};
|
|
23
|
+
// HACK: Polyfill that allows CodeMirror to render in a JSDOM env.
|
|
24
|
+
const createContextualFragment = (html) => {
|
|
25
|
+
const div = document.createElement('div');
|
|
26
|
+
div.innerHTML = html;
|
|
27
|
+
return div.children[0]; // so hokey it's not even funny
|
|
28
|
+
};
|
|
29
|
+
globalThis.Range.prototype.createContextualFragment = (html) => createContextualFragment(html);
|
|
30
|
+
window.document.createRange = function createRange() {
|
|
31
|
+
return {
|
|
32
|
+
setEnd: () => {
|
|
33
|
+
/* no-op */
|
|
34
|
+
},
|
|
35
|
+
setStart: () => {
|
|
36
|
+
/* no-op */
|
|
37
|
+
},
|
|
38
|
+
getBoundingClientRect: () => ({ right: 0 }),
|
|
39
|
+
getClientRects: () => [],
|
|
40
|
+
createContextualFragment
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
// end CodeMirror HACK
|
|
44
|
+
window.focus = () => {
|
|
45
|
+
/* JSDom throws "Not Implemented" */
|
|
46
|
+
};
|
|
47
|
+
window.document.elementFromPoint = (left, top) => document.body;
|
|
48
|
+
if (!window.hasOwnProperty('getSelection')) {
|
|
49
|
+
// Minimal getSelection() that supports a fake selection
|
|
50
|
+
window.getSelection = function getSelection() {
|
|
51
|
+
return {
|
|
52
|
+
_selection: '',
|
|
53
|
+
selectAllChildren: () => {
|
|
54
|
+
this._selection = 'foo';
|
|
55
|
+
},
|
|
56
|
+
toString: () => {
|
|
57
|
+
const val = this._selection;
|
|
58
|
+
this._selection = '';
|
|
59
|
+
return val;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
// Used by xterm.js
|
|
65
|
+
window.matchMedia = function (media) {
|
|
66
|
+
return {
|
|
67
|
+
matches: false,
|
|
68
|
+
media,
|
|
69
|
+
onchange: () => {
|
|
70
|
+
/* empty */
|
|
71
|
+
},
|
|
72
|
+
addEventListener: () => {
|
|
73
|
+
/* empty */
|
|
74
|
+
},
|
|
75
|
+
removeEventListener: () => {
|
|
76
|
+
/* empty */
|
|
77
|
+
},
|
|
78
|
+
dispatchEvent: () => {
|
|
79
|
+
return true;
|
|
80
|
+
},
|
|
81
|
+
addListener: () => {
|
|
82
|
+
/* empty */
|
|
83
|
+
},
|
|
84
|
+
removeListener: () => {
|
|
85
|
+
/* empty */
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
process.on('unhandledRejection', (error, promise) => {
|
|
90
|
+
console.error('Unhandled promise rejection somewhere in tests');
|
|
91
|
+
if (error) {
|
|
92
|
+
console.error(error);
|
|
93
|
+
const stack = error.stack;
|
|
94
|
+
if (stack) {
|
|
95
|
+
console.error(stack);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
promise.catch(err => console.error('promise rejected', err));
|
|
99
|
+
});
|
|
100
|
+
//# sourceMappingURL=jest-shim.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jest-shim.js","sourceRoot":"","sources":["../src/jest-shim.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,sIAAsI;AAEtI,uBAAuB;AAEvB,UAAU,CAAC,SAAS,GAAG,MAAM,SAAS;CAAU,CAAC;AAEjD,IACE,OAAO,UAAU,CAAC,WAAW,KAAK,WAAW;IAC7C,OAAO,UAAU,CAAC,WAAW,KAAK,WAAW,EAC7C;IACA,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7B,UAAU,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;IAC1C,UAAU,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;CAC3C;AAED,MAAM,QAAQ,GAAG,CAAE,MAAc,CAAC,KAAK,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;AAChE,MAAc,CAAC,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;AAC1C,MAAc,CAAC,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;AAC1C,MAAc,CAAC,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC;AAE7C,UAAU,CAAC,KAAK,GAAI,MAAc,CAAC,KAAK,CAAC;AACzC,UAAU,CAAC,KAAK,GAAG,SAAS,KAAK;IAC/B,WAAW;AACb,CAAQ,CAAC;AAET,kEAAkE;AAClE,MAAM,wBAAwB,GAAG,CAAC,IAAY,EAAE,EAAE;IAChD,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC1C,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC;IACrB,OAAO,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CA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ACL,QAAQ,EAAE,GAAG,EAAE;YACb,WAAW;QACb,CAAC;QACD,gBAAgB,EAAE,GAAG,EAAE;YACrB,WAAW;QACb,CAAC;QACD,mBAAmB,EAAE,GAAG,EAAE;YACxB,WAAW;QACb,CAAC;QACD,aAAa,EAAE,GAAG,EAAE;YAClB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,WAAW,EAAE,GAAG,EAAE;YAChB,WAAW;QACb,CAAC;QACD,cAAc,EAAE,GAAG,EAAE;YACnB,WAAW;QACb,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,OAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IAClD,OAAO,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;IAChE,IAAI,KAAK,EAAE;QACT,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACrB,MAAM,KAAK,GAAI,KAAa,CAAC,KAAK,CAAC;QACnC,IAAI,KAAK,EAAE;YACT,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SACtB;KACF;IACD,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAC,CAAC;AAC/D,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { JSONObject } from '@lumino/coreutils';
|
|
2
|
+
/**
|
|
3
|
+
* A Jupyter Server that runs as a child process.
|
|
4
|
+
*
|
|
5
|
+
* ### Notes
|
|
6
|
+
* There can only be one running server at a time, since
|
|
7
|
+
* PageConfig is global. Any classes that use `ServerConnection.ISettings`
|
|
8
|
+
* such as `ServiceManager` should be instantiated after the server
|
|
9
|
+
* has fully started so they pick up the right `PageConfig`.
|
|
10
|
+
*
|
|
11
|
+
* #### Example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const server = new JupyterServer();
|
|
14
|
+
*
|
|
15
|
+
* beforeAll(async () => {
|
|
16
|
+
* await server.start();
|
|
17
|
+
* }, 30000);
|
|
18
|
+
*
|
|
19
|
+
* afterAll(async () => {
|
|
20
|
+
* await server.shutdown();
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
export declare class JupyterServer {
|
|
26
|
+
/**
|
|
27
|
+
* Start the server.
|
|
28
|
+
*
|
|
29
|
+
* @returns A promise that resolves with the url of the server
|
|
30
|
+
*
|
|
31
|
+
* @throws Error if another server is still running.
|
|
32
|
+
*/
|
|
33
|
+
start(options?: Partial<JupyterServer.IOptions>): Promise<string>;
|
|
34
|
+
/**
|
|
35
|
+
* Shut down the server, waiting for it to exit gracefully.
|
|
36
|
+
*/
|
|
37
|
+
shutdown(): Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A namespace for JupyterServer static values.
|
|
41
|
+
*/
|
|
42
|
+
export declare namespace JupyterServer {
|
|
43
|
+
/**
|
|
44
|
+
* Options used to create a new JupyterServer instance.
|
|
45
|
+
*/
|
|
46
|
+
interface IOptions {
|
|
47
|
+
/**
|
|
48
|
+
* Additional Page Config values.
|
|
49
|
+
*/
|
|
50
|
+
pageConfig: {
|
|
51
|
+
[name: string]: string;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Additional traitlet config data.
|
|
55
|
+
*/
|
|
56
|
+
configData: JSONObject;
|
|
57
|
+
/**
|
|
58
|
+
* Map of additional kernelspec names to kernel.json dictionaries
|
|
59
|
+
*/
|
|
60
|
+
additionalKernelSpecs: JSONObject;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) Jupyter Development Team.
|
|
4
|
+
* Distributed under the terms of the Modified BSD License.
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
23
|
+
if (mod && mod.__esModule) return mod;
|
|
24
|
+
var result = {};
|
|
25
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
26
|
+
__setModuleDefault(result, mod);
|
|
27
|
+
return result;
|
|
28
|
+
};
|
|
29
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
30
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
31
|
+
};
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.JupyterServer = void 0;
|
|
34
|
+
/* eslint-disable camelcase */
|
|
35
|
+
// Copyright (c) Jupyter Development Team.
|
|
36
|
+
const child_process_1 = require("child_process");
|
|
37
|
+
const deepmerge_1 = __importDefault(require("deepmerge"));
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
const coreutils_1 = require("@jupyterlab/coreutils");
|
|
41
|
+
const coreutils_2 = require("@lumino/coreutils");
|
|
42
|
+
const common_1 = require("./common");
|
|
43
|
+
/**
|
|
44
|
+
* A Jupyter Server that runs as a child process.
|
|
45
|
+
*
|
|
46
|
+
* ### Notes
|
|
47
|
+
* There can only be one running server at a time, since
|
|
48
|
+
* PageConfig is global. Any classes that use `ServerConnection.ISettings`
|
|
49
|
+
* such as `ServiceManager` should be instantiated after the server
|
|
50
|
+
* has fully started so they pick up the right `PageConfig`.
|
|
51
|
+
*
|
|
52
|
+
* #### Example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* const server = new JupyterServer();
|
|
55
|
+
*
|
|
56
|
+
* beforeAll(async () => {
|
|
57
|
+
* await server.start();
|
|
58
|
+
* }, 30000);
|
|
59
|
+
*
|
|
60
|
+
* afterAll(async () => {
|
|
61
|
+
* await server.shutdown();
|
|
62
|
+
* });
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
*/
|
|
66
|
+
class JupyterServer {
|
|
67
|
+
/**
|
|
68
|
+
* Start the server.
|
|
69
|
+
*
|
|
70
|
+
* @returns A promise that resolves with the url of the server
|
|
71
|
+
*
|
|
72
|
+
* @throws Error if another server is still running.
|
|
73
|
+
*/
|
|
74
|
+
async start(options = {}) {
|
|
75
|
+
if (Private.child !== null) {
|
|
76
|
+
throw Error('Previous server was not disposed');
|
|
77
|
+
}
|
|
78
|
+
const startDelegate = new coreutils_2.PromiseDelegate();
|
|
79
|
+
const env = {
|
|
80
|
+
JUPYTER_CONFIG_DIR: Private.handleConfig(options),
|
|
81
|
+
JUPYTER_DATA_DIR: Private.handleData(options),
|
|
82
|
+
JUPYTER_RUNTIME_DIR: Private.mktempDir('jupyter_runtime'),
|
|
83
|
+
IPYTHONDIR: Private.mktempDir('ipython'),
|
|
84
|
+
PATH: process.env.PATH
|
|
85
|
+
};
|
|
86
|
+
// Create the child process for the server.
|
|
87
|
+
const child = (Private.child = (0, child_process_1.spawn)('jupyter-lab', { env }));
|
|
88
|
+
let started = false;
|
|
89
|
+
// Handle server output.
|
|
90
|
+
const handleOutput = (output) => {
|
|
91
|
+
console.debug(output);
|
|
92
|
+
if (started) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const baseUrl = Private.handleStartup(output);
|
|
96
|
+
if (baseUrl) {
|
|
97
|
+
console.debug('Jupyter Server started');
|
|
98
|
+
started = true;
|
|
99
|
+
void Private.connect(baseUrl, startDelegate);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
child.stdout.on('data', data => {
|
|
103
|
+
handleOutput(String(data));
|
|
104
|
+
});
|
|
105
|
+
child.stderr.on('data', data => {
|
|
106
|
+
handleOutput(String(data));
|
|
107
|
+
});
|
|
108
|
+
const url = await startDelegate.promise;
|
|
109
|
+
return url;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Shut down the server, waiting for it to exit gracefully.
|
|
113
|
+
*/
|
|
114
|
+
async shutdown() {
|
|
115
|
+
if (!Private.child) {
|
|
116
|
+
return Promise.resolve(void 0);
|
|
117
|
+
}
|
|
118
|
+
const stopDelegate = new coreutils_2.PromiseDelegate();
|
|
119
|
+
const child = Private.child;
|
|
120
|
+
child.on('exit', code => {
|
|
121
|
+
Private.child = null;
|
|
122
|
+
if (code !== null && code !== 0) {
|
|
123
|
+
stopDelegate.reject('child process exited with code ' + String(code));
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
stopDelegate.resolve(void 0);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
child.kill();
|
|
130
|
+
window.setTimeout(() => {
|
|
131
|
+
if (Private.child) {
|
|
132
|
+
Private.child.kill(9);
|
|
133
|
+
}
|
|
134
|
+
}, 3000);
|
|
135
|
+
return stopDelegate.promise;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
exports.JupyterServer = JupyterServer;
|
|
139
|
+
/**
|
|
140
|
+
* A namespace for module private data.
|
|
141
|
+
*/
|
|
142
|
+
var Private;
|
|
143
|
+
(function (Private) {
|
|
144
|
+
Private.child = null;
|
|
145
|
+
/**
|
|
146
|
+
* Make a temporary directory.
|
|
147
|
+
*
|
|
148
|
+
* @param suffix the last portion of the dir naem.
|
|
149
|
+
*/
|
|
150
|
+
function mktempDir(suffix) {
|
|
151
|
+
const pathPrefix = '/tmp/jupyterServer';
|
|
152
|
+
if (!fs.existsSync(pathPrefix)) {
|
|
153
|
+
fs.mkdirSync(pathPrefix);
|
|
154
|
+
}
|
|
155
|
+
return fs.mkdtempSync(`${pathPrefix}/${suffix}`);
|
|
156
|
+
}
|
|
157
|
+
Private.mktempDir = mktempDir;
|
|
158
|
+
/**
|
|
159
|
+
* Install a spec in the data directory.
|
|
160
|
+
*/
|
|
161
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
162
|
+
function installSpec(dataDir, name, spec) {
|
|
163
|
+
const specDir = path.join(dataDir, 'kernels', name);
|
|
164
|
+
fs.mkdirSync(specDir, { recursive: true });
|
|
165
|
+
fs.writeFileSync(path.join(specDir, 'kernel.json'), JSON.stringify(spec));
|
|
166
|
+
coreutils_1.PageConfig.setOption(`__kernelSpec_${name}`, JSON.stringify(spec));
|
|
167
|
+
}
|
|
168
|
+
Private.installSpec = installSpec;
|
|
169
|
+
/**
|
|
170
|
+
* Create and populate a notebook directory.
|
|
171
|
+
*/
|
|
172
|
+
function createNotebookDir() {
|
|
173
|
+
const nbDir = mktempDir('notebook');
|
|
174
|
+
fs.mkdirSync(path.join(nbDir, 'src'));
|
|
175
|
+
fs.writeFileSync(path.join(nbDir, 'src', 'temp.txt'), 'hello');
|
|
176
|
+
const roFilepath = path.join(nbDir, 'src', 'readonly-temp.txt');
|
|
177
|
+
fs.writeFileSync(roFilepath, 'hello from a ready only file', {
|
|
178
|
+
mode: 0o444
|
|
179
|
+
});
|
|
180
|
+
return nbDir;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Create a temporary directory for schemas.
|
|
184
|
+
*/
|
|
185
|
+
function createAppDir() {
|
|
186
|
+
const appDir = mktempDir('app');
|
|
187
|
+
// Add a fake static/index.html for `ensure_app_check()`
|
|
188
|
+
fs.mkdirSync(path.join(appDir, 'static'));
|
|
189
|
+
fs.writeFileSync(path.join(appDir, 'static', 'index.html'), 'foo');
|
|
190
|
+
// Add the apputils schema.
|
|
191
|
+
const schemaDir = path.join(appDir, 'schemas');
|
|
192
|
+
fs.mkdirSync(schemaDir, { recursive: true });
|
|
193
|
+
const extensionDir = path.join(schemaDir, '@jupyterlab', 'apputils-extension');
|
|
194
|
+
fs.mkdirSync(extensionDir, { recursive: true });
|
|
195
|
+
// Get schema content.
|
|
196
|
+
const schema = {
|
|
197
|
+
title: 'Theme',
|
|
198
|
+
description: 'Theme manager settings.',
|
|
199
|
+
properties: {
|
|
200
|
+
theme: {
|
|
201
|
+
type: 'string',
|
|
202
|
+
title: 'Selected Theme',
|
|
203
|
+
default: 'JupyterLab Light'
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
type: 'object'
|
|
207
|
+
};
|
|
208
|
+
fs.writeFileSync(path.join(extensionDir, 'themes.json'), JSON.stringify(schema));
|
|
209
|
+
return appDir;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Handle configuration.
|
|
213
|
+
*/
|
|
214
|
+
function handleConfig(options) {
|
|
215
|
+
// Set up configuration.
|
|
216
|
+
const token = coreutils_2.UUID.uuid4();
|
|
217
|
+
coreutils_1.PageConfig.setOption('token', token);
|
|
218
|
+
coreutils_1.PageConfig.setOption('terminalsAvailable', 'true');
|
|
219
|
+
if (options.pageConfig) {
|
|
220
|
+
Object.keys(options.pageConfig).forEach(key => {
|
|
221
|
+
coreutils_1.PageConfig.setOption(key, options.pageConfig[key]);
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
const configDir = mktempDir('config');
|
|
225
|
+
const configPath = path.join(configDir, 'jupyter_server_config.json');
|
|
226
|
+
const root_dir = createNotebookDir();
|
|
227
|
+
const app_dir = createAppDir();
|
|
228
|
+
const user_settings_dir = mktempDir('settings');
|
|
229
|
+
const workspaces_dir = mktempDir('workspaces');
|
|
230
|
+
const configData = (0, deepmerge_1.default)({
|
|
231
|
+
LabApp: {
|
|
232
|
+
user_settings_dir,
|
|
233
|
+
workspaces_dir,
|
|
234
|
+
app_dir,
|
|
235
|
+
open_browser: false,
|
|
236
|
+
log_level: 'DEBUG'
|
|
237
|
+
},
|
|
238
|
+
ServerApp: {
|
|
239
|
+
token,
|
|
240
|
+
root_dir,
|
|
241
|
+
log_level: 'DEBUG'
|
|
242
|
+
},
|
|
243
|
+
MultiKernelManager: {
|
|
244
|
+
default_kernel_name: 'echo'
|
|
245
|
+
},
|
|
246
|
+
KernelManager: {
|
|
247
|
+
shutdown_wait_time: 1.0
|
|
248
|
+
}
|
|
249
|
+
}, options.configData || {});
|
|
250
|
+
coreutils_1.PageConfig.setOption('__configData', JSON.stringify(configData));
|
|
251
|
+
fs.writeFileSync(configPath, JSON.stringify(configData));
|
|
252
|
+
return configDir;
|
|
253
|
+
}
|
|
254
|
+
Private.handleConfig = handleConfig;
|
|
255
|
+
/**
|
|
256
|
+
* Handle data.
|
|
257
|
+
*/
|
|
258
|
+
function handleData(options) {
|
|
259
|
+
const dataDir = mktempDir('data');
|
|
260
|
+
// Install custom specs.
|
|
261
|
+
installSpec(dataDir, 'echo', {
|
|
262
|
+
argv: [
|
|
263
|
+
'python',
|
|
264
|
+
'-m',
|
|
265
|
+
'jupyterlab.tests.echo_kernel',
|
|
266
|
+
'-f',
|
|
267
|
+
'{connection_file}'
|
|
268
|
+
],
|
|
269
|
+
display_name: 'Echo Kernel',
|
|
270
|
+
language: 'echo'
|
|
271
|
+
});
|
|
272
|
+
installSpec(dataDir, 'ipython', {
|
|
273
|
+
argv: ['python', '-m', 'ipykernel_launcher', '-f', '{connection_file}'],
|
|
274
|
+
display_name: 'Python 3',
|
|
275
|
+
language: 'python'
|
|
276
|
+
});
|
|
277
|
+
if (options.additionalKernelSpecs) {
|
|
278
|
+
Object.keys(options.additionalKernelSpecs).forEach(key => {
|
|
279
|
+
installSpec(dataDir, key, options.additionalKernelSpecs[key]);
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
return dataDir;
|
|
283
|
+
}
|
|
284
|
+
Private.handleData = handleData;
|
|
285
|
+
/**
|
|
286
|
+
* Handle process startup.
|
|
287
|
+
*
|
|
288
|
+
* @param output the process output
|
|
289
|
+
*
|
|
290
|
+
* @returns The baseUrl of the server or `null`.
|
|
291
|
+
*/
|
|
292
|
+
function handleStartup(output) {
|
|
293
|
+
let baseUrl = null;
|
|
294
|
+
output.split('\n').forEach(line => {
|
|
295
|
+
const baseUrlMatch = line.match(/(http:\/\/localhost:\d+\/[^?]*)/);
|
|
296
|
+
if (baseUrlMatch) {
|
|
297
|
+
baseUrl = baseUrlMatch[1].replace('/lab', '');
|
|
298
|
+
coreutils_1.PageConfig.setOption('baseUrl', baseUrl);
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
return baseUrl;
|
|
302
|
+
}
|
|
303
|
+
Private.handleStartup = handleStartup;
|
|
304
|
+
/**
|
|
305
|
+
* Connect to the Jupyter server.
|
|
306
|
+
*/
|
|
307
|
+
async function connect(baseUrl, startDelegate) {
|
|
308
|
+
// eslint-disable-next-line
|
|
309
|
+
while (true) {
|
|
310
|
+
try {
|
|
311
|
+
await fetch(coreutils_1.URLExt.join(baseUrl, 'api'));
|
|
312
|
+
startDelegate.resolve(baseUrl);
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
catch (e) {
|
|
316
|
+
// spin until we can connect to the server.
|
|
317
|
+
console.warn(e);
|
|
318
|
+
await (0, common_1.sleep)(1000);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
Private.connect = connect;
|
|
323
|
+
})(Private || (Private = {}));
|
|
324
|
+
//# sourceMappingURL=start_jupyter_server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start_jupyter_server.js","sourceRoot":"","sources":["../src/start_jupyter_server.ts"],"names":[],"mappings":";AAAA;;;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,CAAC;IACjB,CAAC;IA5Be,kBAAU,aA4BzB,CAAA;IAED;;;;;;OAMG;IACH,SAAgB,aAAa,CAAC,MAAc;QAC1C,IAAI,OAAO,GAAkB,IAAI,CAAC;QAClC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAChC,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC;YACnE,IAAI,YAAY,EAAE;gBAChB,OAAO,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;gBAC9C,sBAAU,CAAC,SAAS,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;aAC1C;QACH,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC;IACjB,CAAC;IAVe,qBAAa,gBAU5B,CAAA;IAED;;OAEG;IACI,KAAK,UAAU,OAAO,CAC3B,OAAe,EACf,aAAsC;QAEtC,2BAA2B;QAC3B,OAAO,IAAI,EAAE;YACX,IAAI;gBACF,MAAM,KAAK,CAAC,kBAAM,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;gBACzC,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;gBAC/B,OAAO;aACR;YAAC,OAAO,CAAC,EAAE;gBACV,2CAA2C;gBAC3C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAChB,MAAM,IAAA,cAAK,EAAC,IAAI,CAAC,CAAC;aACnB;SACF;IACH,CAAC;IAhBqB,eAAO,UAgB5B,CAAA;AACH,CAAC,EA/MS,OAAO,KAAP,OAAO,QA+MhB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jupyterlab/testing",
|
|
3
|
+
"version": "4.0.0-alpha.17",
|
|
4
|
+
"description": "JupyterLab basic testing utilities.",
|
|
5
|
+
"homepage": "https://github.com/jupyterlab/jupyterlab",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/jupyterlab/jupyterlab/issues"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/jupyterlab/jupyterlab.git"
|
|
12
|
+
},
|
|
13
|
+
"license": "BSD-3-Clause",
|
|
14
|
+
"author": "Project Jupyter",
|
|
15
|
+
"main": "lib/index.js",
|
|
16
|
+
"types": "lib/index.d.ts",
|
|
17
|
+
"directories": {
|
|
18
|
+
"lib": "lib/"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"lib/**/*.{d.ts,js,js.map,json}"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsc -b",
|
|
25
|
+
"build:all": "npm run build",
|
|
26
|
+
"build:test": "tsc --build tsconfig.test.json",
|
|
27
|
+
"clean": "rimraf lib tsconfig.tsbuildinfo",
|
|
28
|
+
"test": "jest -i",
|
|
29
|
+
"test:cov": "jest -i --collect-coverage",
|
|
30
|
+
"test:debug": "node --inspect-brk node_modules/.bin/jest --runInBand",
|
|
31
|
+
"test:debug:watch": "node --inspect-brk node_modules/.bin/jest --runInBand --watch",
|
|
32
|
+
"watch": "tsc -b --watch"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@babel/core": "^7.10.2",
|
|
36
|
+
"@babel/preset-env": "^7.10.2",
|
|
37
|
+
"@jupyterlab/coreutils": "^6.0.0-alpha.17",
|
|
38
|
+
"@lumino/coreutils": "^2.0.0-alpha.6",
|
|
39
|
+
"@lumino/signaling": "^2.0.0-alpha.6",
|
|
40
|
+
"child_process": "~1.0.2",
|
|
41
|
+
"deepmerge": "^4.2.2",
|
|
42
|
+
"fs-extra": "^10.1.0",
|
|
43
|
+
"identity-obj-proxy": "^3.0.0",
|
|
44
|
+
"jest": "^29.2.0",
|
|
45
|
+
"jest-environment-jsdom": "^29.3.0",
|
|
46
|
+
"jest-junit": "^15.0.0",
|
|
47
|
+
"node-fetch": "^2.6.0",
|
|
48
|
+
"simulate-event": "~1.4.0",
|
|
49
|
+
"ts-jest": "^29.0.0"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@types/jest": "^29.2.0",
|
|
53
|
+
"@types/node": "^14.6.1",
|
|
54
|
+
"@types/node-fetch": "^2.5.4",
|
|
55
|
+
"rimraf": "~3.0.0",
|
|
56
|
+
"typescript": "~4.7.3"
|
|
57
|
+
},
|
|
58
|
+
"publishConfig": {
|
|
59
|
+
"access": "public"
|
|
60
|
+
}
|
|
61
|
+
}
|