@mongosh/node-runtime-worker-thread 1.10.0 → 1.10.2

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.
Files changed (54) hide show
  1. package/.depcheckrc +14 -2
  2. package/.eslintignore +2 -1
  3. package/.eslintrc.js +10 -1
  4. package/.prettierignore +6 -0
  5. package/.prettierrc.json +1 -0
  6. package/dist/child-process-evaluation-listener.d.ts +3 -3
  7. package/dist/child-process-evaluation-listener.js +4 -4
  8. package/dist/child-process-evaluation-listener.js.map +1 -1
  9. package/dist/child-process-mongosh-bus.d.ts +3 -3
  10. package/dist/child-process-mongosh-bus.js +1 -1
  11. package/dist/child-process-mongosh-bus.js.map +1 -1
  12. package/dist/child-process-proxy.js +1 -1
  13. package/dist/child-process-proxy.js.map +1 -1
  14. package/dist/index.d.ts +3 -3
  15. package/dist/index.js +1 -1
  16. package/dist/index.js.map +1 -1
  17. package/dist/lock.d.ts +1 -1
  18. package/dist/lock.js +1 -1
  19. package/dist/lock.js.map +1 -1
  20. package/dist/report.html +2 -2
  21. package/dist/rpc.d.ts +4 -4
  22. package/dist/rpc.js +4 -4
  23. package/dist/rpc.js.map +1 -1
  24. package/dist/serializer.d.ts +3 -3
  25. package/dist/serializer.js +11 -14
  26. package/dist/serializer.js.map +1 -1
  27. package/dist/spawn-child-from-source.d.ts +2 -1
  28. package/dist/spawn-child-from-source.js +1 -1
  29. package/dist/spawn-child-from-source.js.map +1 -1
  30. package/dist/worker-runtime.d.ts +5 -5
  31. package/dist/worker-runtime.js +34 -46
  32. package/dist/worker-runtime.js.map +1 -1
  33. package/package.json +26 -15
  34. package/src/child-process-evaluation-listener.ts +25 -10
  35. package/src/child-process-mongosh-bus.ts +5 -4
  36. package/src/child-process-proxy.spec.ts +22 -12
  37. package/src/child-process-proxy.ts +18 -15
  38. package/src/index.spec.ts +109 -68
  39. package/src/index.ts +25 -13
  40. package/src/lock.spec.ts +9 -9
  41. package/src/lock.ts +1 -1
  42. package/src/rpc.spec.ts +33 -34
  43. package/src/rpc.ts +17 -16
  44. package/src/serializer.spec.ts +85 -63
  45. package/src/serializer.ts +24 -17
  46. package/src/spawn-child-from-source.spec.ts +10 -9
  47. package/src/spawn-child-from-source.ts +5 -5
  48. package/src/worker-runtime.spec.ts +117 -98
  49. package/src/worker-runtime.ts +26 -21
  50. package/tsconfig-lint.json +5 -0
  51. package/tsconfig.json +5 -11
  52. package/tsconfig.test.json +3 -5
  53. package/webpack.config.js +4 -4
  54. package/tsconfig.lint.json +0 -8
@@ -6,10 +6,11 @@ import sinonChai from 'sinon-chai';
6
6
  import sinon from 'sinon';
7
7
  import { EJSON, ObjectId } from 'bson';
8
8
  import { startTestServer } from '../../../testing/integration-testing-hooks';
9
- import { Caller, cancel, close, createCaller, exposeAll, Exposed } from './rpc';
9
+ import type { Caller, Exposed } from './rpc';
10
+ import { cancel, close, createCaller, exposeAll } from './rpc';
10
11
  import { deserializeEvaluationResult } from './serializer';
11
12
  import type { WorkerRuntime } from './worker-runtime';
12
- import { RuntimeEvaluationResult } from '@mongosh/browser-runtime-core';
13
+ import type { RuntimeEvaluationResult } from '@mongosh/browser-runtime-core';
13
14
  import { interrupt } from 'interruptor';
14
15
  import { dummyOptions } from './index.spec';
15
16
 
@@ -27,11 +28,11 @@ function sleep(ms: number) {
27
28
  return new Promise((resolve) => setTimeout(resolve, ms));
28
29
  }
29
30
 
30
- describe('worker', () => {
31
+ describe('worker', function () {
31
32
  let worker: Worker;
32
33
  let caller: Caller<WorkerRuntime>;
33
34
 
34
- beforeEach(async() => {
35
+ beforeEach(async function () {
35
36
  worker = new Worker(workerThreadModule);
36
37
  await once(worker, 'message');
37
38
 
@@ -42,7 +43,7 @@ describe('worker', () => {
42
43
  'getCompletions',
43
44
  'getShellPrompt',
44
45
  'setEvaluationListener',
45
- 'interrupt'
46
+ 'interrupt',
46
47
  ],
47
48
  worker
48
49
  );
@@ -54,7 +55,7 @@ describe('worker', () => {
54
55
  };
55
56
  });
56
57
 
57
- afterEach(async() => {
58
+ afterEach(async function () {
58
59
  if (worker) {
59
60
  // There is a Node.js bug that causes worker process to still be ref-ed
60
61
  // after termination. To work around that, we are unrefing worker manually
@@ -76,7 +77,7 @@ describe('worker', () => {
76
77
  }
77
78
  });
78
79
 
79
- it('should throw if worker is not initialized yet', async() => {
80
+ it('should throw if worker is not initialized yet', async function () {
80
81
  const { evaluate } = caller;
81
82
 
82
83
  let err: Error;
@@ -93,14 +94,14 @@ describe('worker', () => {
93
94
  .match(/Can\'t call evaluate before shell runtime is initiated/);
94
95
  });
95
96
 
96
- describe('evaluate', () => {
97
- describe('basic shell result values', () => {
97
+ describe('evaluate', function () {
98
+ describe('basic shell result values', function () {
98
99
  const primitiveValues: [string, string, unknown][] = [
99
100
  ['null', 'null', null],
100
101
  ['undefined', 'undefined', undefined],
101
102
  ['boolean', '!false', true],
102
103
  ['number', '1+1', 2],
103
- ['string', '"hello"', 'hello']
104
+ ['string', '"hello"', 'hello'],
104
105
  ];
105
106
 
106
107
  const everythingElse: [string, string, string | RegExp][] = [
@@ -108,52 +109,52 @@ describe('worker', () => {
108
109
  [
109
110
  'function with properties',
110
111
  'function def() {}; def.def = 1; def',
111
- '[Function: def] { def: 1 }'
112
+ '[Function: def] { def: 1 }',
112
113
  ],
113
114
  ['anonymous function', '(() => {})', /\[Function.+\]/],
114
115
  ['class constructor', 'class BCD {}; BCD', '[class BCD]'],
115
116
  [
116
117
  'class instalce',
117
118
  'class ABC { constructor() { this.abc = 1; } }; var abc = new ABC(); abc',
118
- 'ABC { abc: 1 }'
119
+ 'ABC { abc: 1 }',
119
120
  ],
120
121
  ['simple array', '[1, 2, 3]', '[ 1, 2, 3 ]'],
121
122
  [
122
123
  'simple array with empty items',
123
124
  '[1, 2,, 4]',
124
- '[ 1, 2, <1 empty item>, 4 ]'
125
+ '[ 1, 2, <1 empty item>, 4 ]',
125
126
  ],
126
127
  [
127
128
  'non-serializable array',
128
129
  '[1, 2, 3, () => {}]',
129
- /\[ 1, 2, 3, \[Function( \(anonymous\))?\] \]/
130
+ /\[ 1, 2, 3, \[Function( \(anonymous\))?\] \]/,
130
131
  ],
131
132
  [
132
133
  'simple object',
133
134
  '({str: "foo", num: 123})',
134
- "{ str: 'foo', num: 123 }"
135
+ "{ str: 'foo', num: 123 }",
135
136
  ],
136
137
  [
137
138
  'non-serializable object',
138
139
  '({str: "foo", num: 123, bool: false, fn() {}})',
139
- "{ str: 'foo', num: 123, bool: false, fn: [Function: fn] }"
140
+ "{ str: 'foo', num: 123, bool: false, fn: [Function: fn] }",
140
141
  ],
141
142
  [
142
143
  'object with bson',
143
144
  '({min: MinKey(), max: MaxKey(), int: NumberInt("1")})',
144
- '{ min: MinKey(), max: MaxKey(), int: Int32(1) }'
145
+ '{ min: MinKey(), max: MaxKey(), int: Int32(1) }',
145
146
  ],
146
147
  [
147
148
  'object with everything',
148
149
  '({ cls: class A{}, fn() {}, bsonType: NumberInt("1"), str: "123"})',
149
- "{ cls: [class A], fn: [Function: fn], bsonType: Int32(1), str: '123' }"
150
- ]
150
+ "{ cls: [class A], fn: [Function: fn], bsonType: Int32(1), str: '123' }",
151
+ ],
151
152
  ];
152
153
 
153
154
  primitiveValues.concat(everythingElse).forEach((testCase) => {
154
155
  const [testName, evalValue, printable] = testCase;
155
156
 
156
- it(testName, async() => {
157
+ it(testName, async function () {
157
158
  const { init, evaluate } = caller;
158
159
  await init('mongodb://nodb/', dummyOptions, { nodb: true });
159
160
  const result = await evaluate(evalValue);
@@ -167,12 +168,12 @@ describe('worker', () => {
167
168
  });
168
169
  });
169
170
 
170
- describe('shell-api results', () => {
171
+ describe('shell-api results', function () {
171
172
  const testServer = startTestServer('shared');
172
173
  const db = `test-db-${Date.now().toString(16)}`;
173
174
  let exposed: Exposed<unknown>;
174
175
 
175
- afterEach(() => {
176
+ afterEach(function () {
176
177
  if (exposed) {
177
178
  exposed[close]();
178
179
  exposed = null;
@@ -190,7 +191,7 @@ describe('worker', () => {
190
191
  ({ printable }: RuntimeEvaluationResult) => {
191
192
  expect(printable.find(({ name }: any) => name === 'admin')).to.not
192
193
  .be.undefined;
193
- }
194
+ },
194
195
  ],
195
196
  ['show collections', 'ShowCollectionsResult', []],
196
197
  ['show profile', 'ShowProfileResult', { count: 0 }],
@@ -200,12 +201,12 @@ describe('worker', () => {
200
201
  ({ printable }: RuntimeEvaluationResult) => {
201
202
  expect(printable.find(({ role }: any) => role === 'dbAdmin')).to.not
202
203
  .be.undefined;
203
- }
204
- ]
204
+ },
205
+ ],
205
206
  ];
206
207
 
207
208
  const useCommand: CommandTestRecord[] = [
208
- [`use ${db}`, null, `switched to db ${db}`]
209
+ [`use ${db}`, null, `switched to db ${db}`],
209
210
  ];
210
211
 
211
212
  const helpCommand: CommandTestRecord[] = [
@@ -217,8 +218,8 @@ describe('worker', () => {
217
218
  expect(printable)
218
219
  .to.have.property('docs')
219
220
  .match(/https:\/\/docs.mongodb.com/);
220
- }
221
- ]
221
+ },
222
+ ],
222
223
  ];
223
224
 
224
225
  const cursors: CommandTestRecord[] = [
@@ -226,7 +227,7 @@ describe('worker', () => {
226
227
  [
227
228
  `use ${db}`,
228
229
  'db.coll.insertOne({ _id: ObjectId("000000000000000000000000"), foo: 321 });',
229
- 'db.coll.aggregate({ $match: { foo: 321 } })'
230
+ 'db.coll.aggregate({ $match: { foo: 321 } })',
230
231
  ],
231
232
  'AggregationCursor',
232
233
  ({ printable }: RuntimeEvaluationResult) => {
@@ -235,35 +236,35 @@ describe('worker', () => {
235
236
  expect(EJSON.serialize(doc)).to.deep.equal(
236
237
  EJSON.serialize({
237
238
  _id: new ObjectId('000000000000000000000000'),
238
- foo: 321
239
+ foo: 321,
239
240
  })
240
241
  );
241
- }
242
+ },
242
243
  ],
243
244
  [
244
245
  [
245
246
  `use ${db}`,
246
247
  'db.coll.insertMany([1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(i => ({ i })))',
247
- 'db.coll.find({ i: { $mod: [2, 0] } }, { _id: 0 })'
248
+ 'db.coll.find({ i: { $mod: [2, 0] } }, { _id: 0 })',
248
249
  ],
249
250
  'Cursor',
250
251
  {
251
252
  documents: [{ i: 2 }, { i: 4 }, { i: 6 }, { i: 8 }, { i: 10 }],
252
- cursorHasMore: false
253
- }
253
+ cursorHasMore: false,
254
+ },
254
255
  ],
255
256
  [
256
257
  [
257
258
  `use ${db}`,
258
259
  "db.coll.insertMany('a'.repeat(100).split('').map(a => ({ a })))",
259
260
  'db.coll.find({}, { _id: 0 })',
260
- 'it'
261
+ 'it',
261
262
  ],
262
263
  'CursorIterationResult',
263
264
  ({ printable }: RuntimeEvaluationResult) => {
264
265
  expect(printable.documents).to.include.deep.members([{ a: 'a' }]);
265
- }
266
- ]
266
+ },
267
+ ],
267
268
  ];
268
269
 
269
270
  const crudCommands: CommandTestRecord[] = [
@@ -275,7 +276,7 @@ describe('worker', () => {
275
276
  expect(printable)
276
277
  .to.have.property('insertedId')
277
278
  .instanceof(ObjectId);
278
- }
279
+ },
279
280
  ],
280
281
  [
281
282
  [`use ${db}`, 'db.coll.insertMany([{ b: "b" }, { c: "c" }])'],
@@ -285,13 +286,13 @@ describe('worker', () => {
285
286
  expect(printable)
286
287
  .to.have.nested.property('insertedIds[0]')
287
288
  .instanceof(ObjectId);
288
- }
289
+ },
289
290
  ],
290
291
  [
291
292
  [
292
293
  `use ${db}`,
293
294
  'db.coll.insertOne({ a: "a" })',
294
- 'db.coll.updateOne({ a: "a" }, { $set: { a: "b" } })'
295
+ 'db.coll.updateOne({ a: "a" }, { $set: { a: "b" } })',
295
296
  ],
296
297
  'UpdateResult',
297
298
  {
@@ -299,17 +300,17 @@ describe('worker', () => {
299
300
  insertedId: null,
300
301
  matchedCount: 1,
301
302
  modifiedCount: 1,
302
- upsertedCount: 0
303
- }
303
+ upsertedCount: 0,
304
+ },
304
305
  ],
305
306
  [
306
307
  [
307
308
  `use ${db}`,
308
309
  'db.coll.insertOne({ a: "a" })',
309
- 'db.coll.deleteOne({ a: "a" })'
310
+ 'db.coll.deleteOne({ a: "a" })',
310
311
  ],
311
312
  'DeleteResult',
312
- { acknowledged: true, deletedCount: 1 }
313
+ { acknowledged: true, deletedCount: 1 },
313
314
  ],
314
315
  [
315
316
  [`use ${db}`, 'db.coll.bulkWrite([{ insertOne: { d: "d" } }])'],
@@ -320,8 +321,8 @@ describe('worker', () => {
320
321
  expect(printable)
321
322
  .to.have.nested.property('insertedIds[0]')
322
323
  .instanceof(ObjectId);
323
- }
324
- ]
324
+ },
325
+ ],
325
326
  ];
326
327
 
327
328
  showCommand
@@ -342,13 +343,16 @@ describe('worker', () => {
342
343
  command = commands;
343
344
  }
344
345
 
345
- it(`"${command}" should return ${resultType} result`, async() => {
346
+ it(`"${command}" should return ${resultType} result`, async function () {
346
347
  // Without this dummy evaluation listener, a request to getConfig()
347
348
  // from the shell leads to a never-resolved Promise.
348
- exposed = exposeAll({
349
- getConfig() {},
350
- validateConfig() {}
351
- }, worker);
349
+ exposed = exposeAll(
350
+ {
351
+ getConfig() {},
352
+ validateConfig() {},
353
+ },
354
+ worker
355
+ );
352
356
 
353
357
  const { init, evaluate } = caller;
354
358
  await init(await testServer.connectionString(), dummyOptions, {});
@@ -376,8 +380,8 @@ describe('worker', () => {
376
380
  });
377
381
  });
378
382
 
379
- describe('errors', () => {
380
- it("should throw an error if it's thrown during evaluation", async() => {
383
+ describe('errors', function () {
384
+ it("should throw an error if it's thrown during evaluation", async function () {
381
385
  const { init, evaluate } = caller;
382
386
 
383
387
  await init('mongodb://nodb/', dummyOptions, { nodb: true });
@@ -397,14 +401,16 @@ describe('worker', () => {
397
401
  .matches(/TypeError: Oh no, types!/);
398
402
  });
399
403
 
400
- it('should preserve extra error properties', async() => {
404
+ it('should preserve extra error properties', async function () {
401
405
  const { init, evaluate } = caller;
402
406
 
403
407
  await init('mongodb://nodb/', dummyOptions, { nodb: true });
404
408
 
405
409
  let err: Error;
406
410
  try {
407
- await evaluate('throw Object.assign(new TypeError("Oh no, types!"), { errInfo: { message: "wrong type :S" } })');
411
+ await evaluate(
412
+ 'throw Object.assign(new TypeError("Oh no, types!"), { errInfo: { message: "wrong type :S" } })'
413
+ );
408
414
  } catch (e: any) {
409
415
  err = e;
410
416
  }
@@ -415,7 +421,7 @@ describe('worker', () => {
415
421
  expect((err as any).errInfo.message).to.equal('wrong type :S');
416
422
  });
417
423
 
418
- it("should return an error if it's returned from evaluation", async() => {
424
+ it("should return an error if it's returned from evaluation", async function () {
419
425
  const { init, evaluate } = caller;
420
426
 
421
427
  await init('mongodb://nodb/', dummyOptions, { nodb: true });
@@ -430,7 +436,7 @@ describe('worker', () => {
430
436
  .matches(/SyntaxError: Syntax!/);
431
437
  });
432
438
 
433
- it('should throw when trying to run two evaluations concurrently', async() => {
439
+ it('should throw when trying to run two evaluations concurrently', async function () {
434
440
  const { init, evaluate } = caller;
435
441
  await init('mongodb://nodb/', dummyOptions, { nodb: true });
436
442
 
@@ -439,7 +445,7 @@ describe('worker', () => {
439
445
  try {
440
446
  await Promise.all([
441
447
  evaluate('sleep(50); 1+1'),
442
- evaluate('sleep(50); 1+1')
448
+ evaluate('sleep(50); 1+1'),
443
449
  ]);
444
450
  } catch (e: any) {
445
451
  err = e;
@@ -455,10 +461,10 @@ describe('worker', () => {
455
461
  });
456
462
  });
457
463
 
458
- describe('getShellPrompt', () => {
464
+ describe('getShellPrompt', function () {
459
465
  const testServer = startTestServer('shared');
460
466
 
461
- it('should return prompt when connected to the server', async() => {
467
+ it('should return prompt when connected to the server', async function () {
462
468
  const { init, getShellPrompt } = caller;
463
469
 
464
470
  await init(await testServer.connectionString());
@@ -469,10 +475,10 @@ describe('worker', () => {
469
475
  });
470
476
  });
471
477
 
472
- describe('getCompletions', () => {
478
+ describe('getCompletions', function () {
473
479
  const testServer = startTestServer('shared');
474
480
 
475
- it('should return completions', async() => {
481
+ it('should return completions', async function () {
476
482
  const { init, getCompletions } = caller;
477
483
 
478
484
  await init(await testServer.connectionString());
@@ -480,12 +486,12 @@ describe('worker', () => {
480
486
  const completions = await getCompletions('db.coll1.f');
481
487
 
482
488
  expect(completions).to.deep.contain({
483
- completion: 'db.coll1.find'
489
+ completion: 'db.coll1.find',
484
490
  });
485
491
  });
486
492
  });
487
493
 
488
- describe('evaluationListener', () => {
494
+ describe('evaluationListener', function () {
489
495
  const spySandbox = sinon.createSandbox();
490
496
 
491
497
  const createSpiedEvaluationListener = () => {
@@ -498,8 +504,10 @@ describe('worker', () => {
498
504
  setConfig() {},
499
505
  resetConfig() {},
500
506
  validateConfig() {},
501
- listConfigOptions() { return ['displayBatchSize']; },
502
- onRunInterruptible() {}
507
+ listConfigOptions() {
508
+ return ['displayBatchSize'];
509
+ },
510
+ onRunInterruptible() {},
503
511
  };
504
512
 
505
513
  spySandbox.spy(evalListener, 'onPrint');
@@ -516,7 +524,7 @@ describe('worker', () => {
516
524
 
517
525
  let exposed: Exposed<unknown>;
518
526
 
519
- afterEach(() => {
527
+ afterEach(function () {
520
528
  if (exposed) {
521
529
  exposed[close]();
522
530
  exposed = null;
@@ -525,8 +533,8 @@ describe('worker', () => {
525
533
  spySandbox.restore();
526
534
  });
527
535
 
528
- describe('onPrint', () => {
529
- it('should be called when shell evaluates `print`', async() => {
536
+ describe('onPrint', function () {
537
+ it('should be called when shell evaluates `print`', async function () {
530
538
  const { init, evaluate } = caller;
531
539
  const evalListener = createSpiedEvaluationListener();
532
540
 
@@ -536,11 +544,11 @@ describe('worker', () => {
536
544
  await evaluate('print("Hi!")');
537
545
 
538
546
  expect(evalListener.onPrint).to.have.been.calledWith([
539
- { printable: 'Hi!', source: undefined, type: null }
547
+ { printable: 'Hi!', source: undefined, type: null },
540
548
  ]);
541
549
  });
542
550
 
543
- it('should correctly serialize bson objects', async() => {
551
+ it('should correctly serialize bson objects', async function () {
544
552
  const { init, evaluate } = caller;
545
553
  const evalListener = createSpiedEvaluationListener();
546
554
 
@@ -550,13 +558,17 @@ describe('worker', () => {
550
558
  await evaluate('print(new ObjectId("62a209b0c7dc31e23ab9da45"))');
551
559
 
552
560
  expect(evalListener.onPrint).to.have.been.calledWith([
553
- { printable: 'ObjectId("62a209b0c7dc31e23ab9da45")', source: undefined, type: 'InspectResult' }
561
+ {
562
+ printable: 'ObjectId("62a209b0c7dc31e23ab9da45")',
563
+ source: undefined,
564
+ type: 'InspectResult',
565
+ },
554
566
  ]);
555
567
  });
556
568
  });
557
569
 
558
- describe('onPrompt', () => {
559
- it('should be called when shell evaluates `passwordPrompt`', async() => {
570
+ describe('onPrompt', function () {
571
+ it('should be called when shell evaluates `passwordPrompt`', async function () {
560
572
  const { init, evaluate } = caller;
561
573
  const evalListener = createSpiedEvaluationListener();
562
574
 
@@ -570,8 +582,8 @@ describe('worker', () => {
570
582
  });
571
583
  });
572
584
 
573
- describe('getConfig', () => {
574
- it('should be called when shell evaluates `config.get()`', async() => {
585
+ describe('getConfig', function () {
586
+ it('should be called when shell evaluates `config.get()`', async function () {
575
587
  const { init, evaluate } = caller;
576
588
  const evalListener = createSpiedEvaluationListener();
577
589
 
@@ -584,8 +596,8 @@ describe('worker', () => {
584
596
  });
585
597
  });
586
598
 
587
- describe('setConfig', () => {
588
- it('should be called when shell evaluates `config.set()`', async() => {
599
+ describe('setConfig', function () {
600
+ it('should be called when shell evaluates `config.set()`', async function () {
589
601
  const { init, evaluate } = caller;
590
602
  const evalListener = createSpiedEvaluationListener();
591
603
 
@@ -594,13 +606,19 @@ describe('worker', () => {
594
606
  await init('mongodb://nodb/', dummyOptions, { nodb: true });
595
607
 
596
608
  await evaluate('config.set("displayBatchSize", 200)');
597
- expect(evalListener.validateConfig).to.have.been.calledWith('displayBatchSize', 200);
598
- expect(evalListener.setConfig).to.have.been.calledWith('displayBatchSize', 200);
609
+ expect(evalListener.validateConfig).to.have.been.calledWith(
610
+ 'displayBatchSize',
611
+ 200
612
+ );
613
+ expect(evalListener.setConfig).to.have.been.calledWith(
614
+ 'displayBatchSize',
615
+ 200
616
+ );
599
617
  });
600
618
  });
601
619
 
602
- describe('resetConfig', () => {
603
- it('should be called when shell evaluates `config.reset()`', async() => {
620
+ describe('resetConfig', function () {
621
+ it('should be called when shell evaluates `config.reset()`', async function () {
604
622
  const { init, evaluate } = caller;
605
623
  const evalListener = createSpiedEvaluationListener();
606
624
 
@@ -609,12 +627,14 @@ describe('worker', () => {
609
627
  await init('mongodb://nodb/', dummyOptions, { nodb: true });
610
628
 
611
629
  await evaluate('config.reset("displayBatchSize")');
612
- expect(evalListener.resetConfig).to.have.been.calledWith('displayBatchSize');
630
+ expect(evalListener.resetConfig).to.have.been.calledWith(
631
+ 'displayBatchSize'
632
+ );
613
633
  });
614
634
  });
615
635
 
616
- describe('listConfigOptions', () => {
617
- it('should be called when shell evaluates `config[asPrintable]`', async() => {
636
+ describe('listConfigOptions', function () {
637
+ it('should be called when shell evaluates `config[asPrintable]`', async function () {
618
638
  const { init, evaluate } = caller;
619
639
  const evalListener = createSpiedEvaluationListener();
620
640
 
@@ -629,8 +649,8 @@ describe('worker', () => {
629
649
  });
630
650
  });
631
651
 
632
- describe('onRunInterruptible', () => {
633
- it('should call callback when interruptible evaluation starts and ends', async() => {
652
+ describe('onRunInterruptible', function () {
653
+ it('should call callback when interruptible evaluation starts and ends', async function () {
634
654
  const { init, evaluate } = caller;
635
655
  const evalListener = createSpiedEvaluationListener();
636
656
 
@@ -639,16 +659,15 @@ describe('worker', () => {
639
659
  await init('mongodb://nodb/', dummyOptions, { nodb: true });
640
660
  await evaluate('1+1');
641
661
 
642
- const [
643
- firstCall,
644
- secondCall
645
- ] = (evalListener.onRunInterruptible as sinon.SinonSpy).args;
662
+ const [firstCall, secondCall] = (
663
+ evalListener.onRunInterruptible as sinon.SinonSpy
664
+ ).args;
646
665
 
647
666
  expect(firstCall[0]).to.have.property('__id');
648
667
  expect(secondCall[0]).to.equal(null);
649
668
  });
650
669
 
651
- it('should return a handle that allows to interrupt the evaluation', async() => {
670
+ it('should return a handle that allows to interrupt the evaluation', async function () {
652
671
  const { init, evaluate } = caller;
653
672
  const evalListener = createSpiedEvaluationListener();
654
673
 
@@ -661,12 +680,12 @@ describe('worker', () => {
661
680
  try {
662
681
  await Promise.all([
663
682
  evaluate('while(true){}'),
664
- (async() => {
683
+ (async () => {
665
684
  await sleep(50);
666
685
  const handle = (evalListener.onRunInterruptible as sinon.SinonSpy)
667
686
  .args[0][0];
668
687
  interrupt(handle);
669
- })()
688
+ })(),
670
689
  ]);
671
690
  } catch (e: any) {
672
691
  err = e;
@@ -680,8 +699,8 @@ describe('worker', () => {
680
699
  });
681
700
  });
682
701
 
683
- describe('interrupt', () => {
684
- it('should interrupt in-flight async tasks', async() => {
702
+ describe('interrupt', function () {
703
+ it('should interrupt in-flight async tasks', async function () {
685
704
  const { init, evaluate, interrupt } = caller;
686
705
 
687
706
  await init('mongodb://nodb/', dummyOptions, { nodb: true });
@@ -691,10 +710,10 @@ describe('worker', () => {
691
710
  try {
692
711
  await Promise.all([
693
712
  evaluate('sleep(100000)'),
694
- (async() => {
713
+ (async () => {
695
714
  await sleep(10);
696
715
  await interrupt();
697
- })()
716
+ })(),
698
717
  ]);
699
718
  } catch (e: any) {
700
719
  err = e;