(
options: { port?: string; pidfilepath?: string } = {}
)
| 591 | })(); |
| 592 | |
| 593 | export function configureMongocryptdSpawnHooks( |
| 594 | options: { port?: string; pidfilepath?: string } = {} |
| 595 | ): { port: string } { |
| 596 | const port = options.port ?? '27022'; |
| 597 | const pidfilepath = options.pidfilepath ?? path.join(tmpdir(), new BSON.ObjectId().toHexString()); |
| 598 | |
| 599 | let childProcess: child_process.ChildProcess; |
| 600 | |
| 601 | beforeEach(async function () { |
| 602 | childProcess = child_process.spawn( |
| 603 | 'mongocryptd', |
| 604 | ['--port', port, '--ipv6', '--pidfilepath', pidfilepath], |
| 605 | { |
| 606 | stdio: 'ignore', |
| 607 | detached: false |
| 608 | } |
| 609 | ); |
| 610 | |
| 611 | childProcess.on('error', error => console.warn(this.currentTest?.fullTitle(), error)); |
| 612 | }); |
| 613 | |
| 614 | afterEach(function () { |
| 615 | childProcess.kill('SIGKILL'); |
| 616 | }); |
| 617 | |
| 618 | return { |
| 619 | port |
| 620 | }; |
| 621 | } |
| 622 | |
| 623 | /** |
| 624 | * A `Runtime` that resolves to entirely Nodejs modules, useful when tests must provide a default `runtime` object to an API. |
no test coverage detected